Closed volkanogretmen closed 4 years ago
here's an example of how to do that:
/// <reference types="cypress" />
Cypress.on('test:before:run:async', () => {
if (Cypress.currentTest.currentRetry() > 0) {
return new Promise((resolve) => setTimeout(resolve, 2000))
}
})
describe('Some flaky suite', () => {
let counter = 0
beforeEach(() => {
Cypress.currentTest.retries(4)
})
it('should pass on 3rd attempt', () => {
counter++
expect(counter === 3, 'some flaky assertion').eq(true)
})
})
I love using this plugin! The only that could make it even better from my point of view is the need to set an interval or "cool-down-period" before commencing the next retry.
So this:
Cypress.currentTest.retries(3)
Could perhaps look like this:
Cypress.currentTest.retries(3, 3000)
Where
3000
stands forms
to wait until next retry is kicked-off.