请您能帮我进行开玩笑的测试。 我的带有redux的create-react-app(es6)会按预期构建并在浏览器中运行。
我认为我的进口商品有问题,但不确定是什么。
您能帮我理解为什么我的笑话测试失败了吗?
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)
FAIL 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.715秒 运行所有测试套件。
观看用法:按w显示更多。
答案 0 :(得分:3)
好像您只是缺少react-redux
和redux
的依赖关系。
只需安装它们:npm install redux react-redux
,您的测试就会通过。