jest
jest copied to clipboard
Construct for repeating tests
🚀 Feature Proposal
An easy way to modify a test to run multiple times until it fails.
Currently possible to change
test
to something like
test.each([...Array(100).keys()])
but it's cumbersome, does not concisely capture the intention, and doesn't stop on failure.
Surrounding test code in a for-loop is also suboptimal since it doesn't execute cleanup code between runs.
Motivation
When debugging a flaky test, it's useful to run it repeatedly until it fails. It would be helpful to be able, with a small code change, to cause a test to run multiple times.
Example
No response
Pitch
Honestly looking for guidance here as to whether something like this belongs in core Jest.
yes, i would love to have this too!
the drawback of using .each is when you have snapshot, it actually will generate each its own snapshot, and not comparing against each run, if the test is flaky, we would not know
the current workaround is i wrap with simple forloop on the test i want to investigate the flakiness on...
but i hope such function like: it.loop(30)(...) exist....
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.
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.
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.