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

后端 未结 2 1134
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-12 08:23

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:

<
2条回答
  •  旧时难觅i
    2021-02-12 09:00

    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.

提交回复
热议问题