npm run test 报错
来源:5-4 添加Button 测试代码 第一部分

慕沐1385803
2022-05-13
Error: Failed to initialize watch plugin “node_modules/jest-watch-typeahead/filename.js”:
● Test suite failed to run
file:///D:/%E7%BB%83%E4%B9%A0/react/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)
at async runCLI (node_modules/@jest/core/build/cli/index.js:173:3)
老师
react 18.1.0 testing-library/jest-dom 5.16.4
npm run test 报这个错 因为啥
写回答
1回答
-
同学你好
我使用你的代码库 运行 npm test 没有遇到任何的错误, 请看截图:
我建议你删除 node_modules 然后重装一次应该就可以了
022022-05-16
相似问题