3

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?

Zebra Propulsion Lab
  • 1,736
  • 1
  • 17
  • 28
  • I get same issue as you, I assume mocha is still doing something in the background as in my instance jake fires the next task but hangs. – Grofit Jul 24 '14 at 20:35

1 Answers1

0

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

jake.addListener('complete', function () {
    console.log('_____finished_____')
    process.exit();
});
Damien Sawyer
  • 5,323
  • 3
  • 44
  • 56