简体   繁体   English

Jest - TypeError:无法读取未定义的属性“fn”

[英]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.

相关问题 未捕获的TypeError:无法读取未定义的属性&#39;fn&#39; - Uncaught TypeError: Cannot read property 'fn' of undefined 把手TypeError:无法读取未定义的属性&#39;fn&#39; - Handlebars TypeError: Cannot read property 'fn' of undefined 开玩笑:TypeError:无法读取未定义的属性“长度” - Jest : TypeError: Cannot read property 'length' of undefined TypeError:无法读取未定义的 Jest 和 Nest 的属性“then” - TypeError: Cannot read property 'then' of undefined Jest and Nest JEST - TypeError:无法读取未定义的属性“then” - JEST - TypeError: Cannot read property 'then' of undefined Jest TypeError:无法读取未定义的属性“id” - Jest TypeError: Cannot read property 'id' of undefined JEST TypeError:无法读取未定义的属性“json” - JEST TypeError: Cannot read property 'json' of undefined 开玩笑-TypeError:无法读取未定义的属性“项目” - Jest - TypeError: Cannot read property 'projects' of undefined 类型错误:无法读取未定义的属性“句柄”---如果(fn.handle && fn.set)mount_app = fn - TypeError: Cannot read property 'handle' of undefined --- if (fn.handle && fn.set) mount_app = fn 无法读取未定义/未捕获类型错误的属性“fn”:$(...).daterangepicker 不是函数 - Cannot read property 'fn' of undefined / Uncaught TypeError: $(...).daterangepicker is not a function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM