jest
jest copied to clipboard
[Feature]: Option for jest.retryTimes to retry just after the test fails
🚀 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.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Not stale
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Not stale
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Not stale
not stale 🍞
I like the idea! jest.retryTimes({immediately: true}) or something? PR welcome 🙂
not stale 🍪
https://github.com/jestjs/jest/releases/tag/v30.0.0-alpha.4
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.