diff --git a/lib/runner.js b/lib/runner.js index d12c5cd9d4..db232125ea 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -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; diff --git a/test/runner.js b/test/runner.js index 04cc583d16..a11aeedabf 100644 --- a/test/runner.js +++ b/test/runner.js @@ -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);