-
-
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
Allow to retry failed test from test context for #1773 #1989
Conversation
longlho
commented
Nov 30, 2015
- make retries run proper hooks
- allow retries override at different levels
@@ -108,6 +110,25 @@ Suite.prototype.timeout = function(ms) { | |||
}; | |||
|
|||
/** | |||
* Set timeout `ms` or short-hand such as "2s". |
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.
Doc comments need updating?
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.
👍
Looks like you may have accidentally deleted mocha.js as part of that commit? Could you amend and restore it? |
@danielstjules my bad :) commit ammended |
* @param {number} retry times | ||
* @return {Mocha} | ||
*/ | ||
Mocha.prototype.retires = function(retries) { |
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.
Typo here retires
-> retries
.
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.
Also the parameter name should be n
? At least it is on your other methods.
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.
ah my bad, fixed
ping @boneskull @danielstjules |
cadf34e
to
b09dc2a
Compare
@@ -0,0 +1,11 @@ | |||
describe('retries', function() { | |||
this.retries(4); |
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.
this.retries(1)
probably makes sense here?
Great job on the tests :) |
@danielstjules tks :) changes made |
Thanks! And can you |
d7aeaf6
to
bdedd85
Compare
done :) |
Playing around with this branch today and will let you know if I have anymore feedback :) |
* Set the number of times to retry failed tests. | ||
* | ||
* @param {Number} retry times | ||
* @return {Mocha} |
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.
Duplicate annotations here
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.
ah, I fixed that, but turns out there're actually a bunch of other methods w/ dupe annotations (timeout
, enableTimeout
...)
Comments aside, the feature looks good to me. :) It behaves exactly as I'd expect:
Integration tests validate that hook behavior is correct with retries. Unless @mochajs/mocha has any objections, I hope to merge this after the comments are fixed. I think it'll fit nicely with a new minor release! :) |
I think mutating the |
What special rule? A developer just needs to read |
- make retries run proper hooks - allow retries override at different levels - expose currentRetry to reporters
bdedd85
to
7d394ab
Compare
@danielstjules changes made :) |
Awesome! Thanks again for all your work on this! I'm sure a lot of people are looking forward to using it :) Should be pretty helpful for browser-based acceptance test suites. |
Allow to retry failed test from test context for #1773
Does this support retrying beforeEach and afterEach hooks too? I have tests that does HTTP calls in |
Also maybe try to retry |
No, just tests, and I'd personally be opposed to the idea of retries for hooks. Hooks serve as setup/teardowns for tests, and can thus be used to cleanup before/after a failed test. For failed hooks (afterEach, after), you can't be sure of the state when retrying. If you have brittle logic in hooks, I'd suggest making a helper function and moving it to be invoked from the specs. |
Awesome! Just saw that this work has been merged and released. Been looking forward to this one. Thanks guys. |
regarding retries in before and after hooks. afterEach(function() {
if(this.isThereAnyErrorsInTheConsole()) {
this.retry(); // fails the test and retries it again
}
}); that's just an explicit retry call that doesn't happen automatically. in my project, we check for react
this is also related to this issue, i assume... #2120 |
I'm currently using this on some of my tests and I love the functionality. I'm currently using |