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

Jakub OlekJakub Olek
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!

0
Subscribe to my newsletter

Read articles from Jakub Olek directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Jakub Olek
Jakub Olek