Jakub Olek
Jakub Olek's simple notes

Jakub Olek's simple notes

How to run a (flaky) test multiple times using Jest

Jakub Olek's photo
Jakub Olek
·Aug 19, 2022·

1 min read

When you discover that your test is flaky - it might be a good idea to run it multiple times to further validate that what you've done to fix actually (maybe) fixes it.

Using Jest it's pretty easy.

You can replace

test("it was flaky", () => {})

with:

test.each(
  Array(100).fill()
)("hopefully it's not flaky anymore", () => {})

Till the next one!

 
Share this