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]: Dynamic test retries based on error messages #15015

Open
airhorns opened this issue Apr 6, 2024 · 1 comment
Open

[Feature]: Dynamic test retries based on error messages #15015

airhorns opened this issue Apr 6, 2024 · 1 comment

Comments

@airhorns
Copy link
Contributor

airhorns commented Apr 6, 2024

馃殌 Feature Proposal

It'd be really nice to be able to selectively retry tests that fail with specific error messages. It's expensive and slow to blindly retry everything, but if you know you have a flake in your CI, it'd be great to overcome it by targeting it specifically and retrying only when it occurs.

Motivation

To help suite reliability, it's nice to retry tests that you know may be flakey. If flake is localized to one test or one suite, it's easy to slap a jest.retryTimes on that suite and be done with it. But, if the flake comes from infrastructure (as it often does), many different suites might use that infrastructure and flake through no fault of their own. Adding a jest.retryTimes to all those suites would work, but can get really expensive in CI if you have some systematic real reason why all those tests are failing that isn't the flake.

Instead of blindly retrying all tests always, it'd be really nice to retry tests that fail with only a certain error message matching a regexp or similar.

Example

// in a global setup
jest.retryTimes(2, { only: [/RST_STREAM_ERROR: some grpc dependency has a flake/] })

Pitch

I can't currently do this from a custom environment as jest-circus is hardcoded to inspect the global retry config once before starting. It can't be adjusted on a per-test basis, or adjusted once the suite has started running. An alternative would be to add or extend the runtime api for adjusting retries to allow it to be called by custom environments, but by-error-message filtering seems common enough to me to include in core.

Copy link

github-actions bot commented May 6, 2024

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 May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant