diff --git a/packages/runner/cypress/support/helpers.js b/packages/runner/cypress/support/helpers.js index 58b2a8716b80..dba886e316fe 100644 --- a/packages/runner/cypress/support/helpers.js +++ b/packages/runner/cypress/support/helpers.js @@ -327,14 +327,16 @@ const createHooks = (win, hooks = []) => { if (fail) { const numFailures = fail - return win[type](() => { + return win[type](function () { + const message = `${type} - ${this._runnable.parent.title || 'root'}` + if (agents) { registerAgents(win) } if (_.isNumber(fail) && fail-- <= 0) { debug(`hook pass after (${numFailures}) failures: ${type}`) - win.assert(true, type) + win.assert(true, message) return } @@ -344,15 +346,15 @@ const createHooks = (win, hooks = []) => { } else { debug(`hook fail: ${type}`) - win.assert(false, type) + win.assert(false, message) throw new Error(`hook failed: ${type}`) } }) } - return win[type](() => { - win.assert(true, type) + return win[type](function () { + win.assert(true, `${type} - ${this._runnable.parent.title || 'root'}`) debug(`hook pass: ${type}`) }) })