【问题标题】:jest-cli code coverage only shows zero percentjest-cli 代码覆盖率仅显示 0%
【发布时间】:2017-07-27 22:18:00
【问题描述】:

由于某种原因,在我的新项目中,我的测试覆盖率始终显示为 0%,即使有测试并且它们显然正在运行。

Test Suites: 3 failed, 4 passed, 7 total
Tests:       4 failed, 21 passed, 25 total
Snapshots:   0 total
Time:        1.849s, estimated 2s
Ran all test suites.

=============================== Coverage summary ===============================
Statements   : 0% ( 0/663 )
Branches     : 0% ( 0/285 )
Functions    : 0% ( 0/117 )
Lines        : 0% ( 0/496 )
================================================================================

我的配置有问题吗?我的测试文件在__tests__,这是我的配置文件中最有趣的配置。

 "jest": 

{
      "automock": true,
      "collectCoverage": true,
      "collectCoverageFrom": [                                                                                                                                                                                                                                                                                                                                          
        "src/js/**/*.js"
      ],
      "coverageReporters": [
        "lcov",
        "text-summary"
      ],
      "coveragePathIgnorePatterns": [
        "<rootDir>/node_modules/"
      ],
      "unmockedModulePathPatterns": [
        "/node_modules/keymirror",
        "serialport"
      ]
}

【问题讨论】:

    标签: node.js unit-testing jestjs


    【解决方案1】:

    "src/js/**/*.js" 更改为"src/js/**/**.js" 是否有帮助? (在 .js 中添加第二个星号)

    【讨论】:

    • 不幸的是,没有。它不会改变任何东西。不过感谢您的回复。
    猜你喜欢
    • 2017-05-31
    • 1970-01-01
    • 2020-08-07
    • 2021-03-01
    • 2015-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-11
    相关资源
    最近更新 更多