【问题标题】:Istanbul :No coverage information was collected, exit without writing coverage information伊斯坦布尔:没有收集到覆盖信息,不写覆盖信息就退出
【发布时间】:2018-06-02 06:43:17
【问题描述】:

我正在尝试获取我的 node.js 项目的代码覆盖率。为此,我正在使用摩卡咖啡和伊斯坦布尔。但我得到0通过 伊斯坦布尔:没有收集到覆盖信息,不写覆盖信息就退出 Mocha 和 istanbul 安装在本地。 package.json 中的脚本看起来像

"scripts": {
    "test": "node_modules/.bin/mocha",
    "test:coverage": "./node_modules/.bin/babel-istanbul cover ./node_modules/.bin/_mocha"
  }

文件夹结构如下 - - -项目 ----node_modules - -测试 - 单元 -01test1.tes.js -02test2.test.js

我的 .istanbul.yml 文件

verbose: false
instrumentation:
    root: ./node_modules/.bin/istanbul
    default-excludes: true
    excludes: []
    embed-source: false
    variable: __coverage__
    compact: true
    preserve-comments: false
    complete-copy: false
    save-baseline: false
    baseline-file: ./coverage/coverage-baseline.json
reporting:
    print: summary
    reports:
        - lcov
    dir: ./coverage
    watermarks:
        statements: [50, 80]
        lines: [50, 80]
        functions: [50, 80]
        branches: [50, 80]
hooks:
    hook-run-in-context: false
    post-require-hook: null

我正在跑步

npm 运行测试:覆盖率

在终端(mac OSX)中。我对此相当陌生,因此非常欢迎任何输入。请帮帮我,我已经花了一整天的时间。

【问题讨论】:

    标签: node.js mocha.js istanbul jscoverage


    【解决方案1】:

    您可以试试default-excludes: false,因为您的测试似乎在 node_modules 下?

    【讨论】:

      【解决方案2】:

      我回复here

      我使用了 babel-node 模块,它适用于我。我在下面使用 命令。

      babel-node node_modules/.bin/babel-istanbul cover _mocha -- --recursive tests/test.*.js --exit
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-04-04
        • 1970-01-01
        • 1970-01-01
        • 2013-12-21
        • 2016-01-22
        • 1970-01-01
        • 2015-07-02
        相关资源
        最近更新 更多