Skip to content

Commit

Permalink
update suite.tests with last retried test
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Feb 14, 2020
1 parent ac12f2c commit a9c2124
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/runner.js
Expand Up @@ -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) {
Expand Down
13 changes: 13 additions & 0 deletions lib/test.js
Expand Up @@ -36,13 +36,26 @@ 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());
test.slow(this.slow());
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;
Expand Down

0 comments on commit a9c2124

Please sign in to comment.