伊斯坦布尔检查覆盖率总是 return true

Istanbul check-coverage always return true

我正在尝试设置 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 run coverage:report 我得到以下输出:

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

所以npm run coverage: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
}

test/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"
},