The Jest configuration does not have to be in the package.json, it can be put in an external file.

Create a .jestrc file

Create a .jestrc file and put your configuration inside. The format is still JSON but the ”jest”: { … }” key at the root is omitted.

package.json
{
[…],
“jest”: {
"testRegex": "tests/.*\\.(js|jsx)$"
},
[…]
}

becomes

.jestrc
{
"testRegex": "tests/.*\\.(js|jsx)$"
}

Use the —config option when calling jest to use the .jestrc file in lieu of the package.json section

$ jest config .jestrc

Enjoy !