[英]Jest - TypeError: Cannot read property 'fn' of undefined
Out of nowhere, I'm having an issue when running certain Jest tests:突然间,我在运行某些 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)
I saw that someone had the same problem here ( https://github.com/facebook/jest/issues/5058 ) but I'm not sure if it ever got resolved.我看到有人在这里( https://github.com/facebook/jest/issues/5058 )遇到了同样的问题,但我不确定它是否得到了解决。 I tried removing node_modules and reinstalling but that didn't fix it.
我尝试删除 node_modules 并重新安装,但这并没有解决。 Wondering if anyone else has had the same error before and how it got resolved?
想知道是否有其他人以前遇到过同样的错误以及它是如何解决的?
I got the same issue in my react app.So i added my jest setup.js file to我在我的反应应用程序中遇到了同样的问题。所以我将我的 jest setup.js 文件添加到
global.jQuery = require('jquery');
after that test worked fine在那次测试后工作正常
So this error actually came up since I was using node v8.9.3.所以这个错误实际上出现了,因为我使用的是 node v8.9.3。 After downgrading back to v6.11.1, this issue went away.
降级回 v6.11.1 后,此问题消失了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.