I have Grunt.js all set up and I wrote my tests which I want to test using mocha-phantomjs.
I just need help to write a task that will run
$ mocha-phantomjs ./tests/index.html
After some looking around I saw that there is a grunt task for running shell commands but isn't there a simpler way ?
I'm new to grunt. I saw that he recognises the grunt qunit
command. Is it built in ? Can't there be something like that for mocha ? Do I have to require child_process and execute it ?
Update: using child_process and executing the command doesn't wait for the end result
You can register test
to a child process (like Yeoman is doing with Testacular):
// Alias the `test` task to run `mocha-phantomjs` instead
grunt.registerTask('test', 'run mocha-phantomjs', function () {
var done = this.async();
require('child_process').exec('mocha-phantomjs ./tests/index.html', function (err, stdout) {
grunt.log.write(stdout);
done(err);
});
});
In the terminal you then just run grunt test
to execute the tests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With