[英]Enabling nyc / istanbul code coverage for files outside the package directory
[英]Unable to use nyc/istanbul for code coverage
我使用nightwatch
进行基于硒的测试,但是当我使用nyc nightwatch
,它只报告测试代码及其 100% 覆盖率。 这是我现在的主要阻滞剂。 我如何获得保障? 基本上,我希望最终将其作为 Jenkins CI 中的报告。
此外,我还想用我的 UT 进行测试,我正在使用jest
。 通常, "test": "jest --coverage"
将正确列出所有测试代码的覆盖范围。 因此,当我进行nyc npm run test
它提供了相同的覆盖范围,这很好。 但是当我只使用nyc jest
运行时,它返回jest.config.js
100% 覆盖率!
我没有mocha
或grunt
等。
由于 jest 在幕后使用 nyc,因此没有理由将它们一起使用。 您可以使用--coverage
标志调用 jest 并告诉它在您的配置中使用哪些报告,如配置中所定义:
"jest": {
"collectCoverage": true,
"collectCoverageFrom": [
"**/*.{js,jsx}",
"!**/node_modules/**",
"!**/vendor/**"
],
"coverageReporters": [
"text",
"cobertura"
],
"reporters": [
"default",
"jest-junit"
]
}
https://jestjs.io/docs/en/configuration#coveragereporters-arraystring
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.