Description
🚀 Feature Proposal
jest.retryTimes() is a great way to deal with flaky tests. It will schedule failed tests to be run AFTER testsuite ends.
Proposition here is to add option, to retry failed test, immidiately after test will fail, without waiting for test suite to finish first.
Motivation
I need to design tests in a different way, when I use and don't use retry
Consider such test suite:
beforeAll() {enable feature A}
testA{use feature A}
testB{disable feature A}
Test design is proper here. I can run all tests together, I can run them separate. But if testA fails, and will be retried after testB, it will fail.
In a perfect world you control wole test env, but this is not always a case with more complex integrations.
Changing design pattern to always use beforeEach{enable feature A}
would cost run time (preparation steps sometimes take more than test itself)
Example
jest.retryTimes(3, {logErrorsBeforeRetry: true, retryFast: true});
Pitch
WIth more complex preparation steps OR when state of one test depends on another test, retrying at the end of testSuite is more risky. Option to retry just after the test - feels safer. This would add more versality for a different uses cases.
Since retry mechanism is already in the core, this feels like natural extensions.