gpt4 book ai didi

babeljs - 测试通过,覆盖率未显示

转载 作者:行者123 更新时间:2023-12-04 08:54:17 26 4
gpt4 key购买 nike

我正在尝试获取 nyc avababel到所有地方都很好。我遇到了 async/await 分支显示为未覆盖的问题,所以这是有效的,我在集成 babel-plugin-istanbul 时遇到问题测试插件。

我在项目中有两个文件,src/index.jssrc/test.js .

{
"name": "example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "ava",
"coverage": "NODE_ENV=test nyc npm run test",
"report": "nyc report --reporter=html",
"report:open": "open ./coverage/index.html",
"cover": "npm run coverage && npm run report && npm run report:open"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"babel-runtime": "^6.26.0",
"bluebird": "^3.5.0",
"lodash": "^4.17.4"
},
"devDependencies": {
"ava": "^0.22.0",
"babel-cli": "^6.26.0",
"babel-plugin-istanbul": "^4.1.4",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.0",
"babel-register": "^6.26.0",
"nyc": "^11.2.1",
"sinon": "^3.2.1",
"testdouble": "^3.2.4"
},
"babel": {
"presets": ["env"],
"plugins": ["transform-runtime"],
"env": {
"test": {
"plugins": ["istanbul"]
}
}
},
"ava": {
"require": ["babel-register"],
"babel": "inherit"
},
"nyc": {
"sourceMap": false,
"instrument": false
}
}

这是正在运行的内容:
> example@1.0.0 coverage /Users/me/Desktop/example
> NODE_ENV=test nyc npm run test


> example@1.0.0 test /Users/me/Desktop/example
> ava


11 passed
----------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
----------|----------|----------|----------|----------|----------------|
All files | Unknown | Unknown | Unknown | Unknown | |
----------|----------|----------|----------|----------|----------------|

> example@1.0.0 report /Users/me/Desktop/example
> nyc report --reporter=html


> example@1.0.0 report:open /Users/em/Desktop/example
> open ./coverage/index.html

为什么不是 src/index.js显示在覆盖范围内?

最佳答案

试着搬家 test.js在某个测试文件夹下 test/test.js

关于babeljs - 测试通过,覆盖率未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46080121/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com