Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
gladykov opened this issue Nov 15, 2023 · 11 comments 路 Fixed by #14977
Closed

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

gladykov opened this issue Nov 15, 2023 · 11 comments 路 Fixed by #14977

Comments

@gladykov
Copy link

馃殌 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.

Copy link

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 github-actions bot added the Stale label Dec 15, 2023
@gladykov
Copy link
Author

Not stale

@github-actions github-actions bot removed the Stale label Dec 15, 2023
Copy link

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 github-actions bot added the Stale label Jan 14, 2024
@gladykov
Copy link
Author

Not stale

@github-actions github-actions bot removed the Stale label Jan 14, 2024
Copy link

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 github-actions bot added the Stale label Feb 13, 2024
@drewdrewthis
Copy link

Not stale

@github-actions github-actions bot removed the Stale label Feb 26, 2024
@jpalmieri
Copy link

not stale 馃崬

@SimenB SimenB added the Pinned label Mar 1, 2024
@SimenB
Copy link
Member

SimenB commented Mar 1, 2024

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

@andrewmclagan
Copy link

not stale 馃崻

@SimenB
Copy link
Member

SimenB commented May 12, 2024

Copy link

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 github-actions bot locked as resolved and limited conversation to collaborators Jun 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants