gpt4 book ai didi

node.js - Istanbul 尔检查覆盖率始终返回 true

转载 作者:太空宇宙 更新时间:2023-11-03 22:29:07 25 4
gpt4 key购买 nike

我正在尝试设置 npm 以使用 istanbul 检查覆盖范围。这是我来自 package.json 的脚本:

"scripts": {
"coverage:report": "istanbul cover _mocha --",
"coverage:check": "istanbul check-coverage",
"test": "./node_modules/.bin/mocha test/hooks.js test/**/*.spec.js",
}

我还有这两个配置文件:

.istanbul.yml

instrumentation:
root: app
check:
global:
statements: 100
lines: 100
branches: 100
functions: 100

mocha.opts

--reporter spec
--ui bdd
--recursive
--colors

当我运行 npm runco​​verage:report 时,我得到以下输出:

=============================== Coverage summary ===============================
Statements : 98.69% ( 301/305 )
Branches : 95.08% ( 58/61 )
Functions : 100% ( 22/22 )
Lines : 98.65% ( 293/297 )
================================================================================

所以 npm runco​​verage:check 应该会失败,但事实并非如此。这是我得到的输出

npm run coverage:check

> ...@2.0.0 coverage:check /home/.../.../...-v2-server
> istanbul check-coverage

我错过了什么?

最佳答案

我仍然不明白为什么它不起作用,但我切换到nyc并且它正在使用以下配置

.nycrc

{
"reporter": [
"lcov",
"text-summary"
],
"include": [
"app/**/*.js",
"test/utils/**/*.js",
"test/fixtures/**/*.js"
],
"exclude": [
"test/**/*.spec.js"
],
"lines": 100,
"statements": 100,
"functions": 100,
"branches": 100,
"check-coverage": true
}

测试/mocha.opts

--reporter spec
--ui bdd
--recursive
--colors

package.json

"scripts": {
"lint": "./node_modules/.bin/eslint *.js --cache",
"lint:fix": "npm run lint -- --fix"
"start": "node -e 'require(\"./app\").start()' | bunyan",
"test": "nyc ./node_modules/.bin/mocha test/hooks.js test/**/*.spec.js"
},

关于node.js - Istanbul 尔检查覆盖率始终返回 true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40346140/

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