ReactJS Test - fsevents is not a function

H. Manner picture H. Manner · Nov 7, 2019 · Viewed 8k times · Source

I am trying to write test cases for my program and I heard good things about testing-library/react and jest-junit. I used npm to install both packages into my devDependencies and change my script for test: "test": 'react-scripts test" When I run npm test, I get and error saying

TypeError: fsevents is not a function

So I tried to npm i fsevents but it did not help. I tried looking online but the errors there were either fsevents is not a constructor or change to yarn.

What is causing this issue? I am using npm v6.4.1 and react-script v3.1.1

Edit: Also using a Mac if that matters

Edi2: I ran the test again and did not get this error anymore without changing anything.

Answer

Aditya Hajare picture Aditya Hajare · Jan 1, 2020

Had similar issue on OSX. If you have Homebrew, just run following command in terminal and try again:

brew install watchman 

If it doesn't help, try running following commands in terminal:

sudo rm -rf (xcode-select -print-path)
xcode-select --install