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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add retryImmediately option to jest.retryTimes (#14696) #14977

Merged
merged 5 commits into from
Mar 26, 2024

Conversation

Vadimchesh
Copy link
Contributor

Summary

Fixes #14696 Added a new property immediately to jest.retryTimes

Test plan

I haven't found a smarter way than using console.log to check the order of test runs.

Copy link

linux-foundation-easycla bot commented Mar 20, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

netlify bot commented Mar 20, 2024

Deploy Preview for jestjs ready!

Name Link
🔨 Latest commit 1870f9c
🔍 Latest deploy log https://app.netlify.com/sites/jestjs/deploys/6602858656221b00082d5e4a
😎 Deploy Preview https://deploy-preview-14977--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment on lines 312 to 314
logErrorsBeforeRetry?: boolean;
waitBeforeRetry?: number;
immediately?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to keep alphabetical order.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@mrazauskas
Copy link
Contributor

mrazauskas commented Mar 20, 2024

Could you add a type test, please? They live here:

expect(jest.retryTimes(3)).type.toEqual<typeof jest>();
expect(jest.retryTimes(3, {logErrorsBeforeRetry: true})).type.toEqual<
typeof jest
>();
expect(jest.retryTimes(3, {logErrorsBeforeRetry: 'all'})).type.toRaiseError();
expect(jest.retryTimes({logErrorsBeforeRetry: true})).type.toRaiseError();
expect(jest.retryTimes(3, {waitBeforeRetry: 1000})).type.toEqual<typeof jest>();
expect(jest.retryTimes(3, {waitBeforeRetry: true})).type.toRaiseError();
expect(jest.retryTimes({logErrorsBeforeRetry: 'all'})).type.toRaiseError();
expect(jest.retryTimes()).type.toRaiseError();

To run the type tests, first build the library:

  • and run yarn test-types;
  • or, to select just this file run yarn tstyche jest-types/__typetests__/jest.test.ts

@@ -1139,6 +1139,16 @@ test('will fail', () => {
});
```

`immediately` option is used to retry the failed test immediately.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just trying to clarify. Feel free to rework.

Suggested change
`immediately` option is used to retry the failed test immediately.
`immediately` option is used to retry the failed test immediately after the failure. If this option is not specified, the tests are retried after Jest is finished running all test in a file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice point, now it's more clear, I'll update PR.

@Vadimchesh Vadimchesh changed the title feat: add immediately option to jest.retryTimes (#14696) feat: add retryImmediately option to jest.retryTimes (#14696) Mar 20, 2024
Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great stuff, thanks!

and thanks for reviewing @mrazauskas 🙇

docs/JestObjectAPI.md Outdated Show resolved Hide resolved
packages/jest-circus/src/run.ts Outdated Show resolved Hide resolved
@SimenB SimenB merged commit 1d682f2 into jestjs:main Mar 26, 2024
8 of 9 checks passed
Copy link

This pull request 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 Apr 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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