Retries and before each not working
See original GitHub issueWhen having an integration/e2e test it might happen that beforeEach could fail. In the example from the documentation: https://mochajs.org/#retry-tests
describe('retries', function() {
// Retry all tests in this suite up to 4 times
this.retries(4);
beforeEach(function() {
browser.get('http://www.yahoo.com');
});
it('should succeed on the 3rd try', function() {
// Specify this test to only retry up to 2 times
this.retries(2);
expect($('.foo').isDisplayed()).to.eventually.be.true;
});
});
It could happen that browser.get fails and we need a retry. Currently, one could have “browser.get” inside the it, but that does not allow to reuse code across tests.
I’d be interested in doing:
beforeEach(function() {
this.retries(2)
browser.get('http://www.yahoo.com');
});
Not sure that it makes 100% sense. If it does not make sense, maybe it would be possible to change the documentation, since it can be slightly misleading:
This feature does re-run beforeEach/afterEach hooks but not before/after hooks.
It could either mean that retries affect beforeEach, or what it actually means, that if the test fails then beforeEach will be executed again.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Cypress E2E: Before hook not working on retries
As a workaround you can use a beforeEach: let isError = false; beforeEach(() => { cy.once('fail', (err) => { isError = true; throw ......
Read more >Test Retries - Cypress Documentation
However, failures in before and after hooks will not trigger a retry. The following is a detailed step-by-step example of how test retries...
Read more >Getting Started - CodeceptJS
If you have a step which often fails, you can retry execution for this single step. Use the retry() function before an action...
Read more >Retry Flaky Tests - WebdriverIO
In order to use the this.retries() method, the suite block describe must use an unbound function function(){} instead of a fat arrow function ......
Read more >Timeouts, retries and backoff with jitter - AWS
To avoid this problem, we employ jitter. This is a random amount of time before making or retrying a request to help prevent...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
this.retries()
has no effect on failing hooks. No hooks or tests will be re-run.this.retries()
does re-run a failing testit()
beforeEach
andafterEach
hooksbefore
andafter
hooksWe updated our docs accordingly, thank you.