Jest: why does it fail with TypeError: Path must b

2019-07-22 08:44发布

I wrote a React application and used jest to write unit tests.

when I run it by "jest --config=jest.config.json --watch" I get the following error:

● Test suite failed to run

TypeError: Path must be a string. Received undefined

  at assertPath (path.js:7:11)
  at Object.relative (path.js:1226:5)

My jest.config.json is:

{
    "snapshotSerializers": [
        "enzyme-to-json/serializer"
    ],
    "transformIgnorePatterns": [
        "node_modules/(?!(react-native|my-project|redux-persist)/)"
    ]
}

1条回答
狗以群分
2楼-- · 2019-07-22 09:20

Since I built my app using create-react-app, I just ran "npm test" and the tests ran successfully.

I understood that Jest is automatically included in the project, and probably adding manually jest to package.json is not effective.

查看更多
登录 后发表回答