【发布时间】:2019-08-23 06:54:58
【问题描述】:
我正在设置 nodejs 以便使用 jest javascript 测试框架测试我的 javascript 代码。我做错了什么?
package.json文件
{
"name": "institute-jest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.26.3",
"babel-jest": "^23.4.0",
"jest": "^23.4.1",
"regenerator-runtime": "^0.12.0"
}
}
在终端中运行npm test 后收到以下错误消息
(node:5088) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'close' of undefined
at Object.<anonymous> (C:\Users\Olakunle-PC\Desktop\nodejs\HomeStudyLabs\node_modules\jest\node_modules\chalk\index.js:72:75)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at _load_chalk (C:\Users\Olakunle-PC\Desktop\nodejs\HomeStudyLabs\node_modules\jest\node_modules\jest-cli\build\cli\index.js:67:43)
at Object.<anonymous> (C:\Users\Olakunle-PC\Desktop\nodejs\HomeStudyLabs\node_modules\jest\node_modules\jest-cli\build\cli\index.js:29:32)
(node:5088) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:5088) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate
the Node.js process with a non-zero exit code.
【问题讨论】:
-
你能显示你的 index.js 文件吗?我认为问题出在那个文件中
标签: javascript node.js npm jestjs