diff --git a/lib/runner.js b/lib/runner.js index 1214121e1e..6716c16c11 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -419,20 +419,6 @@ Runner.prototype.fail = function(test, err, force) { * @param {Error} err */ Runner.prototype.failHook = function(hook, err) { - hook.originalTitle = hook.originalTitle || hook.title; - if (hook.ctx && hook.ctx.currentTest) { - hook.title = - hook.originalTitle + ' for ' + dQuote(hook.ctx.currentTest.title); - } else { - var parentTitle; - if (hook.parent.title) { - parentTitle = hook.parent.title; - } else { - parentTitle = hook.parent.root ? '{root}' : ''; - } - hook.title = hook.originalTitle + ' in ' + dQuote(parentTitle); - } - this.fail(hook, err); }; @@ -456,6 +442,20 @@ Runner.prototype.hook = function(name, fn) { } self.currentRunnable = hook; + hook.originalTitle = hook.originalTitle || hook.title; + if (hook.ctx && hook.ctx.currentTest) { + hook.title = + hook.originalTitle + ' for ' + dQuote(hook.ctx.currentTest.title); + } else { + var parentTitle; + if (hook.parent.title) { + parentTitle = hook.parent.title; + } else { + parentTitle = hook.parent.root ? '{root}' : ''; + } + hook.title = hook.originalTitle + ' in ' + dQuote(parentTitle); + } + if (name === HOOK_TYPE_BEFORE_ALL) { hook.ctx.currentTest = hook.parent.tests[0]; } else if (name === HOOK_TYPE_AFTER_ALL) {