在create-rect应用程序中未通过Jest测试



请帮我运行我的笑话测试。我的create-react应用程序(es6(使用redux构建并按预期在浏览器中运行。

我开玩笑地认为我的进口产品有问题,但不确定是什么。

你能帮我理解为什么我的玩笑考试不及格吗?


FAIL  src/components/__tests__/CommentBox.test.js

●测试套件无法运行

Cannot find module 'react' from 'Provider.js'
However, Jest was able to find:
'components/Provider.js'
You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node'].
See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:259:17)
at Object.<anonymous> (../node_modules/react-redux/lib/components/Provider.js:10:38)

失败src/components/测试/App.test.js●测试套件无法运行

Cannot find module 'react' from 'Provider.js'
However, Jest was able to find:
'components/Provider.js'
You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node'].
See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string
However, Jest was able to find:
'../App.js'
You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node'].
See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:259:17)
at Object.<anonymous> (../node_modules/react-redux/lib/components/Provider.js:10:38)

测试套件:2个失败,共2个测试:共0个快照:共0个时间:4.715s运行所有测试套件。

手表用法:按w键可显示更多信息。

看起来您只是缺少了react-reduxredux依赖项。

只需安装它们:npm install redux react-redux,您的测试就会通过。

最新更新