当前位置: 动力学知识库 > 问答 > 编程问答 >

node.js - Jake async tasks don't terminated after calling complete()

问题描述:

I have this jake task to run all my tests:

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();

}

});

});

But when tests are passed, jake doesn't exit automatically. I have to kill it every time. Did I do anything wrong?

网友答案:

Just a guess, but do you need to add a listener?

jake.addListener('complete', function () {
    console.log('_____finished_____')
    process.exit();
});
分享给朋友:
您可能感兴趣的文章:
随机阅读: