node.js - jest-cli代码覆盖率仅显示零百分比

标签 node.js unit-testing jest

出于某种原因,在我的新项目中,我的测试覆盖率始终显示为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配置。
 "jest": 

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

最佳答案

"src/js/**/*.js"改成"src/js/**/**.js"有帮助吗?(在.js中添加第二个星号)

关于node.js - jest-cli代码覆盖率仅显示零百分比,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45338439/

相关文章:

elasticsearch - 如何在 Jest 中传递多个节点地址(Elasticsearch)

elasticsearch - 浏览所有文档并批量更新其中一些

node.js - typescript jwt.verify 无法访问数据

node.js - 如何使用 Nodejs 生成图像

node.js - 我的 Node JS 应用程序的 Nginx 配置

java - 有没有办法通过 Sonar 或 Hudson 获得准确的测试计数?

unit-testing - 卡夫卡 : Are there are examples on how to use Mockito for unit testing Kafka?

unit-testing - 在 Go 中为 httptest.NewServer 使用自定义 URL

javascript - 获得第一个没有 key 的 firebase child

elasticsearch - 解析内部匹配以及来源