我有这个jake任务来运行我的所有测试:
desc('Run all tests')
task('test', {async: true}, function(args) {
process.env.NODE_ENV = 'test';
var Mocha = require('mocha');
var fs = require('fs'), path = require('path');
var mocha = new Mocha({reporter: 'spec', ui: 'bdd'});
fs.readdirSync('test/unit').forEach(function(file) {
mocha.addFile(path.join('test/unit', file));
});
fs.readdirSync('test/functional').forEach(function(file) {
mocha.addFile(path.join('test/functional', file));
});
mocha.run(function(failures) {
if (failures) {
fail(failures);
} else {
complete();
}
});
});
但是当测试通过时,jake不会自动退出。我每次都要杀了它。我做错了吗?
答案 0 :(得分:0)
只是一个猜测,但你需要添加一个监听器吗?
jake.addListener('complete', function () {
console.log('_____finished_____')
process.exit();
});