How to pass argument from grunt job to karma-runner
I am using grunt-karma to run a unit test package. I need to find the value from a grunt task and then pass the value to karma for use in tests.
The Grunt task doing the search:
grunt.registerMultiTask('lookup', 'Lookup value', function() {
var value = 5; // just hard code here for now
I need to pass the value to the grunt-karma job as defined:
karma: {
options: {
configFile: 'karma.conf.js'
},
Can I use grunt.config to pass karma runner value?
var value = 5; //just hardcode here for now
...
grunt.config("karma.customParam",value);
And how can I get the value from the test specs?
+3
cactusme
source
to share
1 answer
I know this answer is too late. But I hope this helps someone.
karma: {
options: {
configFile: 'karma.conf.js',
client: {
args: ['test']
}
},
In the test spec, you can get the values โโas shown below
window.__karma__.config.args[0] // 'test'
Thank.
+10
JK.Lee
source
to share