Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reporters in config could be a string #45

Closed
dminkovsky opened this issue Aug 7, 2022 · 6 comments
Closed

reporters in config could be a string #45

dminkovsky opened this issue Aug 7, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@dminkovsky
Copy link

dminkovsky commented Aug 7, 2022

Describe the Bug

This tool expects reporters to be undefined or an array:

(config.reporters ??= []).splice(0, config.reporters.length, reporterName);

However, contrary to the docs, Karma 6.3.16 accepts a single string value for reporters as well. Since my config was configured with a single string value, it would have saved me a lot of time if this tool also accepted single string values.

Steps to Reproduce the Behavior

Use a string value for reporters. See that Karma works, but this tool fails due to the line above.

Describe the Expected Behavior

This tool can accept single string reporter values, like Karma.

@dminkovsky dminkovsky added the bug Something isn't working label Aug 7, 2022
@dminkovsky dminkovsky changed the title `reporters in config could be a string: reporters in config could be a string Aug 7, 2022
@lucono
Copy link
Owner

lucono commented Aug 16, 2022

Is this a common pattern to simply specify the reporter name string as the karma.conf.js reporters field when there's only one reporter in use? If so, this can be added in a future release. Otherwise, it seems like an unofficial and undocumented karma config API and it may not make sense to add support for it given that the official API is supported and working as expected.

@dminkovsky
Copy link
Author

dminkovsky commented Aug 16, 2022

Hi @lucono. I don't know whether there's a common usage like that: this is the first Karma config I've seen and I don't know what the origin of it was in the codebase. I just thought I'd report it, because getting this plugin up was quite challenging with this undocumented setting. I think many people would have given up:

  • The error was hidden (you have to know how to look at and find the correct logs in VSCode)
  • Once I found the error, it was unclear what the problem was (sorry I didn't post the error, but it was something like "splice is undefined" with a trace to the line above).

But, whatever you decide to do with this issue, even if you close it, it'll be searchable on The Web :)

Thank you for this tool! It's been great.

@dminkovsky
Copy link
Author

Here's the error. It's in "Karma Server" output:

------------------------------------
Karma Test Explorer: Launching Karma
------------------------------------

16 08 2022 09:29:26.499:ERROR [config]: Error in config file!
 TypeError: (intermediate value)(intermediate value)(intermediate value).splice is not a function
    at lt.addReporter (/Users/dmitry/.vscode/extensions/lucono.karma-test-explorer-0.7.3/dist/karma.conf.js:2:9956)
    at module.exports (/Users/dmitry/.vscode/extensions/lucono.karma-test-explorer-0.7.3/dist/karma.conf.js:2:10571)
    at Object.parseConfig (/Users/dmitry/dev/editor-html/node_modules/karma/lib/config.js:469:26)
    at Object.exports.run (/Users/dmitry/dev/editor-html/node_modules/karma/lib/cli.js:288:26)
    at Object.<anonymous> (/Users/dmitry/dev/editor-html/node_modules/karma/bin/karma:3:23)
    at Module._compile (node:internal/modules/cjs/loader:1163:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1216:10)
    at Module.load (node:internal/modules/cjs/loader:1035:32)
    at Module._load (node:internal/modules/cjs/loader:876:12)
    at Function.c._load (node:electron/js2c/asar_bundle:5:13343)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47

@lucono
Copy link
Owner

lucono commented Aug 23, 2022

@dminkovsky Try out the fix in the beta branch to confirm if it resolves the issue. You can use the vsix from the CI build, or build it yourself from the beta branch.

@dminkovsky
Copy link
Author

Seems to be working! :)

Screen Shot 2022-08-24 at 7 18 21 AM

@lucono
Copy link
Owner

lucono commented Aug 27, 2022

Released in v0.7.4

@lucono lucono closed this as completed Aug 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants