【问题标题】:JestJS Tests failing internally with request-promise-coreJestJS 使用 request-promise-core 内部测试失败
【发布时间】:2018-01-07 17:43:54
【问题描述】:

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

这是我的 package.json 开发依赖项:

"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:

无法读取未定义的属性“原型”。

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

如果我启动节点调试器工具,options.request.Request 是未定义的。有没有人遇到过这种情况?

完整的错误堆栈是:

 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)

【问题讨论】:

    标签: javascript unit-testing jestjs


    【解决方案1】:

    试试npm install --save-dev request

    【讨论】:

      【解决方案2】:

      这个特殊问题的问题并不是我正在做的任何事情。我有一些包依赖项在导入时不起作用。

      【讨论】:

        猜你喜欢
        • 2017-11-14
        • 2018-06-29
        • 1970-01-01
        • 1970-01-01
        • 2021-09-15
        • 1970-01-01
        • 2021-04-24
        • 2023-03-03
        • 1970-01-01
        相关资源
        最近更新 更多