Search code examples
javascriptreactjstestingjestjscreate-react-app

How to use jest.config.js with create-react-app


I would like to move my jest config out of my package.json, i am trying to use the --config as suggested here but get the error argv.config.match is not a function

package.json

  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --config jest.config.js",
    "eject": "react-scripts eject",
  },

cli

hutber@hutber-mac:/var/www/management/node$ npm test -u

> [email protected] test /var/www/management/node
> react-scripts test --config jest.config.js

Usage: test.js [--config=<pathToConfigFile>] [TestPathPattern]


argv.config.match is not a function
npm ERR! Test failed.  See above for more details.

Solution

  • For me appending -- --config=jest.config.js worked.

    So the whole string react-scripts test -- --config jest.config.js in your case.