【问题标题】:No code coverage in Babel JestBabel Jest 中没有代码覆盖
【发布时间】:2016-03-09 13:20:45
【问题描述】:

我的代码覆盖率有问题。这是测试结果:

[...]
24 tests passed (24 total in 9 test suites, run time 2.353s)
----------|----------|----------|----------|----------|----------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
----------|----------|----------|----------|----------|----------------|
----------|----------|----------|----------|----------|----------------|
All files |      100 |      100 |      100 |      100 |                |
----------|----------|----------|----------|----------|----------------|

All reports generated

Process finished with exit code 0

我所有的测试都成功了(预计计数 73)。但是没有封面。我只是在测试正常的节点代码。我使用 babel-jest,这里有 package.json 中的配置:

"scripts": {
  "test": "jest"
},
"jest": {
  "collectCoverage": true,
  "moduleFileExtensions": [
    "js",
    "json"
  ],
  "scriptPreprocessor": "<rootDir>/node_modules/babel-jest",
  "testDirectoryName": "unit",
  "testFileExtensions": [
    "js"
  ],
  "testPathDirs": [
    "<rootDir>/tests/"
  ]
}

这是我的项目架构:

./
|-- app
|   |-- routes
|   |   |-- private
|   |   |-- public
|-- tests
|   |-- unit
|   |   |-- routes
|   |   |   |-- private
|   |   |   |-- public

如您所见,tests/unit 文件夹包含与 app 文件夹相同的架构。

您知道为什么我没有任何报告吗?提前致谢!

【问题讨论】:

    标签: babeljs jestjs istanbul


    【解决方案1】:

    终于有答案了。这是 Babel 中的一个错误。看看如何解决这个问题:https://github.com/facebook/jest/issues/632。在 Jest 0.9.0 中修复。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-26
      • 2016-06-02
      • 2020-12-26
      相关资源
      最近更新 更多