gulp-mocha: Gulp-Mocha fails to exit, but Mocha does
Hi,
I am running a simple test (its failing, but that a separate issue).
Using:
"gulp-mocha": "^1.0.0",
When I run this using Gulp-Mocha (it happens on Travis as well), it does not exit the testing execution, but when I run this using Mocha, it fails, and exits back to the command prompt.
var assert = require("assert"),
elasticsearch = require('elasticsearch'),
client;
client = new elasticsearch.Client();
describe(' people', function(){
beforeEach(function(done){
//in Gulp Mocha this stops the test runner exiting
//that this does not work is not this issue.
client.deleteByQuery({
index: 'people',
q: '*'
}, function (error, response) {
done();
});
//If i just do done(), it will exit. in both.
//done();
});
describe('add a entry into the index', function(){
it('should add Dave as a person to the database', function(done){
assert.equal(1,1);
});
});
});
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 53 (14 by maintainers)
Commits related to this issue
- Added stubs to avoid console output, stopped server.test from automatic testing as it doesn't close gulp-mocha properly. tried https://github.com/sindresorhus/gulp-mocha#test-suite-not-exiting and sol... — committed to boris-arkenaar/javascript-examiner by Oizor 9 years ago
- gulp test hangs - https://github.com/sindresorhus/gulp-mocha/issues/54 — committed to snoe/node-host by deleted user 8 years ago
- Adding travis-ci build Add build status to README gulp test hangs - https://github.com/sindresorhus/gulp-mocha/issues/54 — committed to snoe/node-host by deleted user 8 years ago
- Adding travis-ci build Add build status to README gulp test hangs - https://github.com/sindresorhus/gulp-mocha/issues/54 — committed to snoe/node-host by deleted user 8 years ago
- Adding travis-ci build Add build status to README gulp test hangs - https://github.com/sindresorhus/gulp-mocha/issues/54 — committed to snoe/node-host by deleted user 8 years ago
- Adding travis-ci build Add build status to README gulp test hangs - https://github.com/sindresorhus/gulp-mocha/issues/54 — committed to neovim/node-host by deleted user 8 years ago
Saw this trick in another issue.
Had same issue. The cause was a mongoose connection that was opened but not properly caused on tests. Adding
fixed this for me.
Fixed for me: https://github.com/dreame4/gulp-exit
Using gulp-spawn-mocha fixes the problem for me.
@scippio It may not close its connections at all. That’s the case. TJ a while ago discussed why it was good to put
process.exit()
in mocha CLI. People argued that developers should take care of closing their connections so mocha doesn’t hang and TJ said yes, people should, but a lot of libraries don’t so we useprocess.exit()
to force them to close their connections.I ended up closing my connections manually and everything works fine but I see the case to use
process.exit()
if you don’t want to worry with it or if you use one library that behaves bad and doesn’t close its connections.