繁体   English   中英

Babel Jest中没有代码覆盖率

[英]No code coverage in Babel Jest

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

[...]
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文件夹相同的体系结构。

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM