-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement repeats
#5011
base: main
Are you sure you want to change the base?
feat: implement repeats
#5011
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -814,6 +814,14 @@ Runner.prototype.runTests = function (suite, fn) { | |
self.fail(test, err); | ||
} | ||
self.emit(constants.EVENT_TEST_END, test); | ||
return self.hookUp(HOOK_TYPE_AFTER_EACH, next); | ||
} else if (test.currentRepeat() < test.repeats()) { | ||
var repeatedTest = test.clone(); | ||
repeatedTest.currentRepeat(test.currentRepeat() + 1); | ||
tests.unshift(repeatedTest); | ||
|
||
self.emit(constants.EVENT_TEST_RETRY, test, null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Refactor] 🤔 I think a "retry" is different from a "repeat" as designed. I think we'd want a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree (especially since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm yeah that's a good point. I think it'd be reasonable to leave out the event for now. We can always add it in if folks ask. Taking one out is much harder. Will also want to hear from @mochajs/maintenance-crew on this (and the PR in general, per the review note). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, and per #5011: if there's no event then I think it'd be especially valuable to make sure test contexts have the current repeat count. |
||
|
||
return self.hookUp(HOOK_TYPE_AFTER_EACH, next); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
describe('repeats suite', function() { | ||
let calls = 0; | ||
this.repeats(3); | ||
|
||
it('should pass', function() { | ||
|
||
}); | ||
|
||
it('should fail on the second call', function () { | ||
calls++; | ||
console.log(`RUN: ${calls}`); | ||
if (calls > 1) throw new Error(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
describe('repeats', function () { | ||
it('should pass', () => undefined); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Praise] Very good line to have. The distinction between the
repeat
andretries
could be tricky for folks to understand. I like having this clear explanation!