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

Give karma.config.js access to command line arguments #1561

Closed
danielsiwiec opened this issue Aug 14, 2015 · 8 comments · Fixed by mozilla/payments-ui#444 · May be fixed by Omrisnyk/npm-lockfiles#122 or Omrisnyk/npm-lockfiles#132
Closed

Comments

@danielsiwiec
Copy link
Contributor

Currently, the config argument passed into karma.config.js is an empty object, that gets filled out. It would be beneficial, to have access to command line arguments from within the configuration, through the passed config object, as this would allow custom logic, based on those arguments to be applied.

Example scenario: There are two test suites (eg. unit and component) in two different folders. It's desired to run only the selected test suite. This could easily be achieved by passing an argument on the command line (like suite=unit), that karma.config.js would have access to and would set the proper value on the config.files property.

What do people think about it? The implementation of this would be very straightforward (basically a one-liner).

@dtabuenc
Copy link

This would definitely be useful, such as for turning on/off coverage instrumentation via commandline when using non-standard processors like webpack.

@dignifiedquire
Copy link
Member

I agree, and can see how this could be useful. If someone wants to work on this I'd be happy to accept a PR

@danielsiwiec
Copy link
Contributor Author

Cool. I'll submit a PR for this. Thanks!

@naganowl
Copy link

A workaround that currently exists would is #61 (comment).

I'm planning on using the suggestion in order to toggle coverage as @dtabuenc mentioned.

@danielsiwiec
Copy link
Contributor Author

PR submitted

dignifiedquire added a commit that referenced this issue Sep 9, 2015
…config

feat(scope): Pass CLI arguments to karma.config.js. Closes #1561
@dignifiedquire
Copy link
Member

@danielsiwiec could you make a PR with some docs about this please? Thanks

@danielsiwiec
Copy link
Contributor Author

Good idea. Will do shortly

@JamieMason
Copy link

Thanks @dignifiedquire @danielcompton.

I figured out after posting that it's mentioned in the OP (resolved config is under config.*).

snickell added a commit to code-dot-org/code-dot-org that referenced this issue Sep 20, 2023
CLI args are passed to karma on the config object
See: karma-runner/karma#1561
snickell added a commit to code-dot-org/code-dot-org that referenced this issue Feb 3, 2024
CLI args are passed to karma on the config object
See: karma-runner/karma#1561
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment