[英]Grouping istanbul code coverage report by folder
我正在使用 istanbul 和 nyc 命令运行 NodeJs 的代码覆盖率报告。
我正在使用 mocha 进行单元测试
正如预期的那样,我得到了每个文件的报告,但我希望看到的是具有单个目录摘要的报告。 让我更详细地解释一下我得到了什么以及我想看到什么
我所有的源文件都在一个文件夹中,我想查看该文件夹的摘要,而不是该文件夹中每个文件的完整列表
这是我的文件夹结构的样子
// This is the folder where all the sources are at
src
// This is the folder where coverage is output
coverage
NodeJs
index.html
file1.js
file2.js
file3.js
// This is the folder where all tests are at
tests
test_file1.js
test_file2.js
test_file3.js
我的.babelrc
文件看起来像这样
{
"presets": ["es2015", "stage-2"],
"plugins": [
[
"istanbul",
{"exclude": ["**/tests/*.js"]}
]
]
}
我正在使用以下命令运行覆盖率测试
node ./node_modules/.bin/nyc --reporter=html \
--report-dir=./src/coverage/NodeJs \
./node_modules/mocha/bin/_mocha \
--require babel-core/register \
--ui bdd src/tests/test*.js
我所有的测试都运行良好,它们通过了,并且报告按预期将 output 发送到src/coverage/NodeJs/index.html
文件。 在浏览器中,该报告如下所示:
我想看到的是这样的,我可以看到整个文件夹的单个完整摘要,然后在必要时单击文件夹以深入其中,如下所示:
现在,如果我有超过 1 个被覆盖的文件夹,我可以得到那种效果。 例如...如果我摆脱了.babelrc
文件中的exclude
项,那么将覆盖 2 个目录( src
和src/tests
),我会得到每个目录的摘要,就像这样
但问题是我不希望我的测试被覆盖......正如你所看到的,它弄乱了数字。 我只想覆盖一个文件夹,并希望在 HTML output 文件中查看单个文件夹摘要。
关于如何实现这一目标的任何建议? (如果我没有提供足够的信息,请告诉我)
您不能将输出重定向到同一个文件夹,即统一保存所有结果的文件夹吗?
这可能会有所帮助!
或者也许不是单独的 Instabul,也可以尝试将NYC添加为:
我的 .babelrc 文件看起来像这样
{
"presets": ["es2015", "stage-2"],
"plugins": [
[
"istanbul","NYC",
{"exclude": ["**/tests/*.js"]}
]
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.