jest icon indicating copy to clipboard operation
jest copied to clipboard

Construct for repeating tests

Open ikonst opened this issue 3 years ago • 1 comments

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

ikonst avatar Aug 15 '22 02:08 ikonst

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

rickvian avatar Sep 09 '22 07:09 rickvian

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 Oct 09 '22 07:10 github-actions[bot]

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.

github-actions[bot] avatar Nov 08 '22 07:11 github-actions[bot]

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.

github-actions[bot] avatar Nov 08 '22 07:11 github-actions[bot]

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 Dec 09 '22 00:12 github-actions[bot]