Skip to content

Commit

Permalink
Merge pull request #859 from aearly/bug/bail-hooks
Browse files Browse the repository at this point in the history
Prevent subsequent hooks from being called if we are `--bail`ing.
  • Loading branch information
tj committed May 23, 2013
2 parents cdf1162 + 3f2d701 commit 7f124a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ Runner.prototype.hook = function(name, fn){
function next(i) {
var hook = hooks[i];
if (!hook) return fn();
if (self.failures && suite.bail()) return fn();
self.currentRunnable = hook;

self.emit('hook', hook);
Expand Down
5 changes: 5 additions & 0 deletions test/acceptance/misc/bail.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ describe('bail', function(){
})

describe('bail-2', function(){

before(function (done) {
throw new Error('this hook should not be displayed');
})

it('should not display this error', function(done){
throw new Error('this should not be displayed');
})
Expand Down

0 comments on commit 7f124a2

Please sign in to comment.