Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create react app tests not running without any changes to the code

I ran create-react-app.

Made no changes and ran the tests.

The tests failed straight away.

Error: Failed to initialize watch plugin "node_modules/jest-watch-typeahead/filename.js":

● Test suite failed to run

file:///C:/_Projects/my-app/node_modules/jest-watch-typeahead/build/file_name_plugin/prompt.js:4
import { PatternPrompt, printPatternCaret, printRestoredPatternCaret } from 'jest-watcher';
         ^^^^^^^^^^^^^
SyntaxError: The requested module 'jest-watcher' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export.
For example:
import pkg from 'jest-watcher';
const { PatternPrompt, printPatternCaret, printRestoredPatternCaret } = pkg;

  at async requireOrImportModule (node_modules/jest-util/build/requireOrImportModule.js:65:32)
  at async watch (node_modules/@jest/core/build/watch.js:337:34)
  at async _run10000 (node_modules/@jest/core/build/cli/index.js:311:7)

What the deuce?

Can anyone please help?

like image 228
CraftyFox Avatar asked Nov 18 '25 13:11

CraftyFox


1 Answers

This is a known issue and is related to the version of node you are using. Check out https://github.com/facebook/create-react-app/issues/11792.

Resolve it by upgrading to the latest node version >16. This worked for me. https://nodejs.org/en/download/

like image 150
Diamondista Avatar answered Nov 21 '25 04:11

Diamondista



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!