我已经设置好了Grunt.js,并且我编写了我想要使用mocha-phantomjs进行测试的测试。
我只是需要帮助来编写一个将运行的任务
$ mocha-phantomjs ./tests/index.html 在环顾四周之后,我发现运行shell命令有一个繁琐的任务,但是没有更简单的方法吗?
我是个新手。我看到他识别grunt qunit命令。它是内置的吗?莫卡咖啡就不能有这样的东西吗?我必须要求child_process并执行它吗?
更新:使用child_process并执行命令不会等待最终结果
发布于 2013-01-13 18:54:22
您可以将test注册到子进程(就像约曼对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);
});
});在终端中,您只需运行grunt test来执行测试。
发布于 2013-06-03 17:11:38
我知道这很旧,但是有一个grunt-mocha任务可以在phantomjs中运行mocha测试。
https://stackoverflow.com/questions/14302702
复制相似问题