Skip to content

Commit

Permalink
after hooks now being called on failed tests when using bail, fixes m…
Browse files Browse the repository at this point in the history
  • Loading branch information
dasilvacontin authored and tandrewnichols committed Dec 15, 2014
1 parent 8a58268 commit df2b610
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 df2b610

Please sign in to comment.