Chris Hansen
Chris Hansen

Reputation: 8685

jest.config is being ignored

I have the following in my jest.config.js

module.exports = {
    preset: 'ts-jest/presets/js-with-ts',
    testEnvironment: 'jsdom'
};

but it's being ignored when I run npm test. Can someone please help?

Here's my package.json

  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },

Upvotes: 3

Views: 10363

Answers (2)

ItsIgzy
ItsIgzy

Reputation: 445

Have in mind that you are probablly overriding the defaults so you need to make a require as stated in the documentation Jest Documentation scroll to defaults

Just making a module.exports isn't enough.

Upvotes: 0

Robin Michay
Robin Michay

Reputation: 817

Seems like adding -- --config=jest.config.js is enough.

You can try to replace the scripts "test" in package.json by react-scripts test -- --config=jest.config.js, else you can set the jest config directly into the package.json

You can find the answer here : How to use jest.config.js with create-react-app

Upvotes: 3

Related Questions