MaxwellLynn
MaxwellLynn

Reputation: 968

Create React App - Can't run npm run test

I've had to eject my Create React App and now I can run my tests but the watch is completely broken.

If my tests fail or pass they do not carry on watching and I get the below error instead.

Error watching file for changes: EMFILE
Failed at the [email protected] test script 'node scripts/test.js --env=jsdom'.

I get this error when running npm run test

I've tried installing watchman to see if this made a difference with no success.

another thing that I've tried is adding the below line to my package.json file:

"setupTestFrameworkScriptFile": "<rootDir>/src/setupTests.js",

Upvotes: 1

Views: 1495

Answers (1)

MaxwellLynn
MaxwellLynn

Reputation: 968

I feel like someone else might get this issue so I'm going to say how I fixed it.

It turns out that I need to run the below commands and your tests will be watching test files again.

rm -rf ./node_modules
npm cache clean
npm install

I must of been out of sync or something.. Such a simple thing to do to fix a really annoying problem.

Upvotes: 1

Related Questions