Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

91
Views
How to set Jest test retries globally

Some of my test files in Jest are flaky. Identifying individual files and adding jest.retryTimes(2) to the top of those files helps. I would like to add that as a global setting rather than needing to add that line to the top of every file.

Is there a way to configure Jest so that it will always retry failed tests rather than needing to add that setting in each file?

Thanks!

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use setupFilesAfterEnv:[array] in your jest config file https://jestjs.io/docs/configuration#setupfilesafterenv-array

Make a setup file (e.g setup-jest.js) and include the jest.retryTimes(2) in there.

// setup-jest.js

jest.retryTimes(2)


// jest.config.js

module.exports = {
  setupFilesAfterEnv: ['<rootDir>/setup-jest.js'],
  ...
};
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!