question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

jest.retryTimes doesn't work

See original GitHub issue

I’m trying to setup retry mechanism that uses jest-circus runner. I did follow exactly sample but it didn’t work. I remember it used to work before, but now it couldn’t work anymore. My code is below, could you please give me some glue?

jest.retryTimes(3)
it('will fail', () => {
  expect(true).toBe(false)
})

My running command is: yarn test "<path to the test>" --testRunner="jest-circus/runner" --runInBand Type script: 4.0.2 Jest: 24.0.13 Jest-circus: 26.6.3 Node: 10.12.27

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
minipunchcommented, Oct 25, 2021

So I actually found myself here thinking the same thing, i.e. that jest.retryTimes was not working…

However I just realized I was being misled since it just doesn’t output anything in console to tell you it is retrying the test – instead it just does it silently

So it is indeed actually working as expected, as the e2e tests linked above actually shows if you run it yourself

So the OP’s example test will always say failing even with his retry statement since true will never become false by itself, even after 3 tries

0reactions
github-actions[bot]commented, Dec 25, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to make a jest test fail at first time even using jest ...
not working. i'm setting retryTimes(4) in a script loaded by setupFilesAfterEnv in the jest.config.js , but even setting retryTimes(1) in ...
Read more >
The Jest Object
retryTimes(numRetries, options) ​. Runs failed tests n-times until they pass or until the max number of retries is exhausted. options are ...
Read more >
Why auto-retry test execution in a test framework is wrong?
jest.retryTimes(3) //set maximum retries number describe('Test', ... that adding 'retryTimes' to a test framework does not sound 'right'.
Read more >
Jest Object (API Reference) - w3resource
This will only work with jest-circus! A test Example: jest.retryTimes(3); test('will fail', () => { expect(true).toBe( ...
Read more >
The Jest Object - API Manual
Runs failed tests n-times until they pass or until the max number of retries is exhausted. This only works with jest-circus! Example in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found