create-react-app: React-scripts test command not working

Describe the bug

react-scripts test command stopped working after update to ^4.0.3 from ^3.0.0.

It shows this error on terminal:

● Validation Error:

  Watch plugin jest-watch-typeahead/filename cannot be found. Make sure the watchPlugins configuration option points to an existing node module.

  Configuration Documentation:
  https://jestjs.io/docs/configuration.html

error Command failed with exit code 1.

Nothing has changed on the code. Only react-scripts package. Tests were working fine before the update. The project is not ejected and it is not intended to be.

Did you try recovering your dependencies?

Yes, I tried. yarn version: 1.22.10

Which terms did you search for in User Guide?

I’ve search for ‘react-scripts test’ and ‘watchPlugins’ and all I found is that I need to eject the project. I don’t understand why. It was never like that. So I think that is not the solution to the problem.

Steps to reproduce

  1. Open a terminal on the CRA project root
  2. Run yarn
  3. Run yarn test

Expected behavior

I expect tests run fine. Like before updating to ^4.0.3.

Actual behavior

react-scripts test command stops working after update react-scripts library to ^4.0.3 from ^3.0.0.

It shows this error on terminal:

● Validation Error:

  Watch plugin jest-watch-typeahead/filename cannot be found. Make sure the watchPlugins configuration option points to an existing node module.

  Configuration Documentation:
  https://jestjs.io/docs/configuration.html

error Command failed with exit code 1.

Thank you 😄

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 23
  • Comments: 19

Commits related to this issue

Most upvoted comments

I have had the same issue and one important thing to notice is that the newest released version of jest-watch-typeahead is now written in native ESM and will break with the following error:

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module

Make sure to install the version compatible with Jest 26 e non native ESM modules.

yarn add --exact jest-watch-typeahead@0.6.5

I’ve fixed it by installing the plugin jest-watch-typeahead

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

Had the same issue after updating react-scripts 4.0.35.0.1.

It’s not necessary to add jest-watch-typeahead as a dependency to the package.json, no-save install was enough in my case: npm install --no-save jest-watch-typeahead@1.1.0

Running npm ci might be more robust solution, though.

I noticed that I didn’t have jest-watch-typeahead in my node_modules. Installing it solved the problem:

npm install --save-dev jest-watch-typeahead

That’s a workaround of course rather than solving the problem.