[英]Jest - TypeError: Cannot read property 'fn' of undefined
突然間,我在運行某些 Jest 測試時遇到了問題:
Summary of all failing tests
FAIL server/controllers/voice/settings/__tests__/voice.settings.controller.test.js
● Test suite failed to run
TypeError: Cannot read property 'fn' of undefined
at Runtime._createJestObjectFor (node_modules/jest-runner/node_modules/jest-runtime/build/index.js:734:35)
at handle (node_modules/worker-farm/lib/child/index.js:44:8)
at process.<anonymous> (node_modules/worker-farm/lib/child/index.js:51:3)
at emitTwo (events.js:126:13)
at process.emit (events.js:214:7)
我看到有人在這里( https://github.com/facebook/jest/issues/5058 )遇到了同樣的問題,但我不確定它是否得到了解決。 我嘗試刪除 node_modules 並重新安裝,但這並沒有解決。 想知道是否有其他人以前遇到過同樣的錯誤以及它是如何解決的?
我在我的反應應用程序中遇到了同樣的問題。所以我將我的 jest setup.js 文件添加到
global.jQuery = require('jquery');
在那次測試后工作正常
所以這個錯誤實際上出現了,因為我使用的是 node v8.9.3。 降級回 v6.11.1 后,此問題消失了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.