Skip to content

Commit

Permalink
Merge pull request #1409 from dasilvacontin/fix/missingHooksWithBail
Browse files Browse the repository at this point in the history
fixes #1093: missing hooks after failed test with bail
  • Loading branch information
Travis Jeffery committed Nov 27, 2014
2 parents 9cb8a91 + 607eb92 commit a3454e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ 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;

hook.ctx.currentTest = self.test;
Expand Down
14 changes: 14 additions & 0 deletions test/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,20 @@ describe('Runner', function(){
})
})

describe('.hook(name, fn)', function(){
it('should execute hooks after failed test if suite bail is true', function(done){
runner.fail({});
suite.bail(true);
suite.afterEach(function(){
suite.afterAll(function() {
done();
})
});
runner.hook('afterEach', function(){});
runner.hook('afterAll', function(){});
})
})

describe('.fail(test, err)', function(){
it('should increment .failures', function(){
runner.failures.should.equal(0);
Expand Down

0 comments on commit a3454e3

Please sign in to comment.