Skip to content

Commit

Permalink
Add --no-exit flag to prevent process.exit() call (close #1018)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianc authored and travisjeffery committed Nov 6, 2013
1 parent 8bec097 commit b43cb7f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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)
})
})

0 comments on commit b43cb7f

Please sign in to comment.