TypeError: environment.setup is not a function in React Testing

后端 未结 7 1799
伪装坚强ぢ
伪装坚强ぢ 2021-02-12 08:44

I was trying to implement the example shown in Jest website: Getting started with Jest.

While running npm test on I was getting the following error:

<
7条回答
  •  伪装坚强ぢ
    2021-02-12 08:57

    Jest is included with react-scripts. The error is due to a conflict that arose when you installed Jest in a project started with react-scripts. The "Getting started with Jest" guide expects a 'clean' project.

    Simply remove Jest from your (dev)dependencies and it should work.

    If you want to use Jest for testing React components (which you probably do), you need to modify your test script in package.json to react-scripts test --env=jsdom, as it was.

提交回复
热议问题