Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make process.exit optional #1018

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bin/_mocha
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ program
.option('--reporters', 'display available reporters')
.option('--compilers <ext>:<module>,...', 'use the given module(s) to compile files', list, [])
.option('--inline-diffs', 'display actual/expected differences inline within each string')
.option('--no-exit', 'require a clean shutdown of the event loop: mocha will not call process.exit')

program.name = 'mocha';

Expand Down Expand Up @@ -347,7 +348,7 @@ if (program.watch) {
// load

mocha.files = files;
mocha.run(process.exit);
mocha.run(program.exit ? process.exit : function() {});

// enable growl notifications

Expand Down
13 changes: 13 additions & 0 deletions test/acceptance/misc/exit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
describe('exit', function(){
//note --bail works nicely in that it still allows an 'early exit' in an error scenario
it('should not exit even in error scenario if called with --no-exit', function(done){
done(new Error('failure'));
})

it('should take a long time to exit if called with --no-exit', function(done){
done();
setTimeout(function() {
console.log('all done');
}, 2500)
})
})