本文介绍了JestJS测试在内部因request-promise-core而失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我所有的笑话测试都突然失败了.我正在测试es6代码.

All of my jest tests are suddenly failing. I am testing es6 code.

这是我的package.json devDepenencies:

Here is my package.json devDepenencies:

"devDependencies": {
"babel-eslint": "^8.1.2",
"babel-jest": "^22.0.4",
"babel-preset-es2015": "^6.24.1",
"can-connect": "^1.5.14",
"can-fixture": "^1.2.2",
"documentjs": "^0.5.1",
"eslint": "^4.14.0",
"http-server": "^0.10.0",
"jest": "^22.0.4",
"jquery": "^3.2.1",
"jquery-ui": "^1.12.1",
"json-pretty-html": "^1.0.2",
"regenerator-runtime": "^0.11.1",
"steal-css": "^1.3.1",
"steal-less": "^1.2.2",
"steal-stache": "^3.1.3",
"steal-tools": "^1.10.0"
},

每个测试中的错误都来自34:48上的文件request-promise-core/configure/request2:

The error in each test comes from the file request-promise-core/configure/request2 on 34:48:

无法读取未定义的属性"prototype".

Cannot read property 'prototype' of undefined.

var originalInit = options.request.Request.prototype.init;

如果启动节点调试器工具,则

options.request.Request是未定义的.有人遇到过这个吗?

options.request.Request is undefined if I launch the node debugger tool. Has anyone run into this before?

完整的错误堆栈为:

 FAIL  util\field\parseFieldArray\parseFieldArray.test.js
  ● Test suite failed to run

TypeError: Cannot read property 'prototype' of undefined

  at module.exports (node_modules/request-promise-core/configure/request2.js:34:48)
  at Object.<anonymous> (node_modules/request-promise-native/lib/rp.js:15:1)
  at Object.<anonymous> (node_modules/jsdom/lib/api.js:6:17)

推荐答案

与这个特定问题无关的并不是我在做什么.我有一些导入时无法使用的程序包依赖项.

The issue with this particular problem wasn't really anything I was doing. I had some package dependencies that weren't working when imported.

这篇关于JestJS测试在内部因request-promise-core而失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 15:44