使用NYC和基于JEST的E2E测试框架的NYC覆盖不正确的代码覆盖范围
我正在尝试为单个E2E测试用例生成代码覆盖范围。这是我为实现这一目标所做的。
- 使用NYC与E2E测试案例有关的仪器文件。请注意,我在此处使用了仪器
- 执行的测试用例。
- 使用
窗口.__覆盖范围__
存储的覆盖范围报告 .nyc_output/coverage.json 。 - 使用
NYC报告生成的报告-Reporter = LCOV -REPORTER = TEXT
命令。创建的Coverage文件夹
我可以看到它显示了分支,线语句仪器代码的功能。实际上,它应该显示语句,原始代码的行。
这是我的NYCRC文件。
{
"extends": "nyc-config-tsx",
"exclude": [
"**/*.test.tsx",
"**/*.mock.tsx",
"**/*.test.ts",
"**/*.mock.ts"
],
"extension": [
".js",
".ts",
".jsx",
".tsx"
],
"exclude-after-remap": false,
"all": true,
"cache": false,
"source-map": true,
"produce-source-map": true
}
I am trying to generate code coverage for the single e2e test case. Here is what I did to achieve this.
- Instrumented files related to e2e test case using nyc. Note here I used in place instrumentation
- Executed test cases.
- stored coverage report using
window.__coverage__
into.nyc_output/coverage.json
. - generated report using
nyc report --reporter=lcov --reporter=text
command. created coverage folder
I can see that its showing branches , lines statements functions of instrumented code. Actually it should show statement , lines of original code.
Here is my nycrc file.
{
"extends": "nyc-config-tsx",
"exclude": [
"**/*.test.tsx",
"**/*.mock.tsx",
"**/*.test.ts",
"**/*.mock.ts"
],
"extension": [
".js",
".ts",
".jsx",
".tsx"
],
"exclude-after-remap": false,
"all": true,
"cache": false,
"source-map": true,
"produce-source-map": true
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论