简体   繁体   English

当在 react 中运行 npm test 时,Jest 给了我下面的消息,我要做的就是运行它默认在 App.test.js 中的测试

[英]When running npm test in react Jest is giving me the message below and All I am trying to do is run the test it comes by default inside App.test.js

● Test suite failed to run ● 测试套件运行失败

Cannot find module 'C:\Users.....\node_modules\grpc\src\node\extension_binary\node-v72-win32-x64-unknown\grpc_node.node' from 'grpc_extension.js'

However, Jest was able to find:
    './grpc_extension.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']. “json”、“web.jsx”、“jsx”、“节点”]。

See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string     

However, Jest was able to find:
    './client_interceptors.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']. “json”、“web.jsx”、“jsx”、“节点”]。

See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string     

However, Jest was able to find:
    '../api/api-firebase.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', 

PASS src/App.test.js FAIL src/pages/InventoryItems.test.js ● Test suite failed to run PASS src/App.test.js FAIL src/pages/InventoryItems.test.js ● 测试套件运行失败

Cannot find module 'C:\Users\el_mo\Boom\BoomAdmin\boom-platform-admin-portal\node_modules\grpc\src\node\extension_binary\node-v72-win32-x64-unknown\grpc_node.node' from 'grpc_extension.js'

However, Jest was able to find:
    './grpc_extension.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']. “json”、“web.jsx”、“jsx”、“节点”]。

See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string     

However, Jest was able to find:
    './client_interceptors.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']. “json”、“web.jsx”、“jsx”、“节点”]。

See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string     

However, Jest was able to find:
    '../api/api-firebase.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']. “json”、“web.jsx”、“jsx”、“节点”]。

'json', 'web.jsx', 'jsx', 'node']. “json”、“web.jsx”、“jsx”、“节点”]。

See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

However, Jest was able to find:
    './InventoryItems.test.js'
    './InventoryItems.tsx'

You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['web.js'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/grpc/src/grpc_extension.js:32:13)

Test Suites: 1 failed, 1 passed, 2 total Tests: 1 passed, 1 total Snapshots: 0 total Time: 5.856s Ran all test suites related to changed files.测试套件:1 次失败,1 次通过,总共 2 次测试:1 次通过,总共 1 个快照:总共 0 次时间:5.856 秒运行与更改文件相关的所有测试套件。

So I finally solved it!!所以我终于解决了!! I had to downgrade node's version, then I had to re-install react-scripts.我不得不降级 node 的版本,然后我不得不重新安装 react-scripts。 The node version that I used was 6.14.8我使用的节点版本是 6.14.8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM