Open
Description
Describe the bug
Running tests (using npm test
) for a newly created app throws the error:
Error: Failed to initialize watch plugin "node_modules/jest-watch-typeahead/filename.js":
● Test suite failed to run
file:///Users/dannyskoog/GIT/test-version-5/node_modules/jest-watch-typeahead/build/file_name_plugin/prompt.js:4
import { PatternPrompt, printPatternCaret, printRestoredPatternCaret } from 'jest-watcher';
^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'printPatternCaret' not found. The requested module 'jest-watcher' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
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)
at async runCLI (node_modules/@jest/core/build/cli/index.js:173:3)
Did you try recovering your dependencies?
Yes
Which terms did you search for in User Guide?
https://create-react-app.dev/docs/troubleshooting/
Environment
node (via nvm): 14.15.4
npm (via nvm): 6.14.10
create-react-app: 5.0.0
Steps to reproduce
(Write your steps here:)
npx create-react-app my-app --template typescript
cd my-app
npm test
Expected behavior
Tests should be executed
Actual behavior
An error is thrown before the watcher is set up and tests are ran
Workaround
Running npm i -D --exact [email protected]
solves the problem (as suggested here #11043 (comment))