@dedrick
To pass arguments/parameters to mocha tests invoked via grunt, you can use the -- notation to separate the arguments/parameters for the grunt task and for the mocha test.
Here's an example of how you can pass arguments/parameters to mocha tests invoked via grunt:
1 2 3 4 5 6 7 8 9 |
grunt.registerTask('test', 'Run Mocha tests', function() {
var args = Array.prototype.slice.call(arguments, 0);
grunt.util.spawn({
cmd: 'mocha',
args: ['test/**/*.js'].concat(args),
}, function(error, result, code) {
// Handle error
});
});
|
1 2 3 4 5 |
{
"scripts": {
"test": "grunt test -- --reporter spec --timeout 5000"
}
}
|
In the above example, the --reporter spec and --timeout 5000 arguments are passed to the mocha tests via the grunt task.
1
|
npm test |
This will run the mocha tests via grunt with the specified arguments/parameters.