伊斯坦布尔检查报道总是回归真实

时间:2016-10-31 16:11:50

标签: node.js mocha code-coverage istanbul

我尝试设置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

我错过了什么?

1 个答案:

答案 0 :(得分:0)

我仍然不知道为什么它不起作用,但我切换到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"
},