jest icon indicating copy to clipboard operation
jest copied to clipboard

[Feature]: Option for jest.retryTimes to retry just after the test fails

Open gladykov opened this issue 2 years ago • 5 comments

🚀 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.

gladykov avatar Nov 15 '23 12:11 gladykov

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.

github-actions[bot] avatar Dec 15 '23 13:12 github-actions[bot]

Not stale

gladykov avatar Dec 15 '23 13:12 gladykov

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.

github-actions[bot] avatar Jan 14 '24 14:01 github-actions[bot]

Not stale

gladykov avatar Jan 14 '24 16:01 gladykov

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.

github-actions[bot] avatar Feb 13 '24 17:02 github-actions[bot]

Not stale

drewdrewthis avatar Feb 26 '24 11:02 drewdrewthis

not stale 🍞

jpalmieri avatar Feb 29 '24 23:02 jpalmieri

I like the idea! jest.retryTimes({immediately: true}) or something? PR welcome 🙂

SimenB avatar Mar 01 '24 15:03 SimenB

not stale 🍪

andrewmclagan avatar Apr 17 '24 03:04 andrewmclagan

https://github.com/jestjs/jest/releases/tag/v30.0.0-alpha.4

SimenB avatar May 12 '24 21:05 SimenB

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.

github-actions[bot] avatar Jun 12 '24 00:06 github-actions[bot]