Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set JestJS global timeout in package.json

Tags:

jestjs

I am wondering how would I set up a global timeout for all my JestJS tests within package.json?

The default 5000ms is not sufficient for my tests. I don't want to be doing the following code for each of my tests:

it('should return foo', () => { .. }, timeout);
like image 787
Jon Avatar asked Nov 25 '19 18:11

Jon


1 Answers

You can add testTimeout to your jest configuration

package.json
"jest": {
  "testTimeout": 10000,
}

or as a CLI option

package.json
"scripts": {
  "test": "jest --testTimeout=10000"
}

If you get the following warning

● Validation Warning:

Unknown option "testTimeout" with value 10000 was found. This is probably a typing mistake. Fixing it will remove this message.

you should upgrade jest

like image 126
Teneff Avatar answered Sep 28 '22 11:09

Teneff