-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat: pass command line arguments for start
command
#672
Comments
Put it to the config file, exactly as you do with any other config variable. |
module.exports = function(config) {
config.set({
client: {
args: ['--foo', 'bar'],
// other client-side config
captureConsole: false
}
});
}; |
That works if you only ever want to pass one set of arguments, but my example was specifically using the same config but passing different arguments for different runs. e.g one run uses In which case you'd have to maintain one config file for each set of arguments you want to use. Surely that doesn't count as a sufficiently usable workaround, so can we please reopen this? |
Having a side channel that's not explicitly on the command line would be acceptable, personally. e.g:
|
Yep, you can use env variables: // karma.conf.js
module.exports = function(config) {
config.set({
client: {
args: process.env.KARMA_CLIENT_ARGS.split(',')
}
});
}; |
Right, that would work. But actually asking users to always cut & paste that code into each config they write (or have it silently fail to recognise arguments) seems kinda user-hostile. It would be much harder to misconfigure if this were baked into karma-runner itself somewhere. |
@vojtajina the start command is where it makes sense to pass clientArgs, at least for grunt-karma and grep. Otherwise you have to use grunt watch instead of karma's watch.
|
Also without this you can't grep when doing a singleRun, since it doesn't ever call run. |
@vojtajina sadly my use case lost to @gfxmonk's and grep does not work. In #574 I originally made it pass the args through on |
@geddski grunt-karma can pass anything to the client, it can set the "client" config property, which gets passed to the browser... |
@vojtajina hmm you're right, |
@vojtajina yep it was my use of the requirejs adapter, forgot to pass in the config on |
I proposed a change in order to allow start to accept clientArgs |
@gaelazzo @timbertson A bit late to the party, but since this there's a much simpler solution now:
karma.conf.js: module.exports = function (config) {
config.set({
...,
client: {
args: ['--grep', config.grep]
}
})
} |
Many thanks. |
@danielsiwiec, still getting
None of those commands above seems to make any diference.
Is it really possible run a single test? |
Following on from #530
We now have:
But that sucks for batch runs (like CI scripts), because you need to:
karma start
karma run -- <args>
There is real need for this feature, e.g segmenting travis builds by test type:
karma start --single-run -- --tag unit
karma start --single-run -- --tag integration
Options:
--
as clientArgs, just like we do forrun
.@vojtajina doesn't like this, because it removes the possibility of using this for something else in the future.
--client-args
would trigger that ALL following arguments should be taken as clientArgs:karma start --single-run --client-args --grep unit
This should probably grab only up to the next "--" argument though.
karma start --single-run --client-arg=--grep --client-arg=unit
Other suggestions?
The text was updated successfully, but these errors were encountered: