Javascript Jest-TypeError:无法读取属性';fn';未定义的
我在运行某些Jest测试时遇到了一个问题:Javascript Jest-TypeError:无法读取属性';fn';未定义的,javascript,testing,enzyme,jestjs,Javascript,Testing,Enzyme,Jestjs,我在运行某些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._createJestO
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)
所有失败测试的总结
服务器/控制器/语音/设置/测试失败\uuuuu/voice.settings.controller.test.js
● 测试套件无法运行
TypeError:无法读取未定义的属性“fn”
运行时。_createJestObjectFor(node_modules/jest runner/node_modules/jest Runtime/build/index.js:734:35)
在句柄(node_modules/worker farm/lib/child/index.js:44:8)
但我不确定它是否得到了解决。我试着移除节点模块并重新安装,但没有解决问题。想知道以前是否有其他人也有过同样的错误,以及它是如何解决的?所以这个错误实际上是在我使用node v8.9.3时出现的。降级回v6.11.1后,这个问题消失了。我在react应用程序中遇到了同样的问题。因此我将我的jest setup.js文件添加到
global.jQuery = require('jquery');
在该测试运行良好之后您能否向我们展示失败的测试以及另一个使用jest.fn
但未失败的测试用例的示例?