diff --git a/lib/runner.js b/lib/runner.js index f96b020320..17fa290432 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -135,6 +135,11 @@ function Runner(suite, delay) { this.total = suite.total(); this.failures = 0; this.on(constants.EVENT_TEST_END, function(test) { + if (test.retriedTest() && test.parent) { + var idx = + test.parent.tests && test.parent.tests.indexOf(test.retriedTest()); + if (idx > -1) test.parent.tests[idx] = test; + } self.checkGlobals(test); }); this.on(constants.EVENT_HOOK_END, function(hook) { diff --git a/lib/test.js b/lib/test.js index f32008a85b..65122b260c 100644 --- a/lib/test.js +++ b/lib/test.js @@ -36,6 +36,18 @@ function Test(title, fn) { */ utils.inherits(Test, Runnable); +/** + * Set or get retried test + * + * @private + */ +Test.prototype.retriedTest = function(n) { + if (!arguments.length) { + return this._retriedTest; + } + this._retriedTest = n; +}; + Test.prototype.clone = function() { var test = new Test(this.title, this.fn); test.timeout(this.timeout()); @@ -43,6 +55,7 @@ Test.prototype.clone = function() { test.enableTimeouts(this.enableTimeouts()); test.retries(this.retries()); test.currentRetry(this.currentRetry()); + test.retriedTest(this.retriedTest() || this); test.globals(this.globals()); test.parent = this.parent; test.file = this.file;