【发布时间】:2020-06-21 22:59:05
【问题描述】:
请您帮我运行我的笑话测试。 我的带有 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)
失败 src/components/tests/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 显示更多。
【问题讨论】:
标签: reactjs jestjs create-react-app