![](/img/trans.png)
[英]Istanbul code coverage checking coverage of my spec files instead of source?
[英]Istanbul coverage with mocha test cases only showing coverage report for spec files (test files)
伊斯坦布尔覆盖报告仅显示规格文件(即测试文件)的覆盖报告,而不显示原始路由器和控制器文件。
它显示规格文件的100%覆盖率和路由器文件的0%。
我正在使用的命令是npm test:
"test": "NODE_ENV=development istanbul cover --include-all-sources --root ./server ./node_modules/.bin/_mocha -- --compilers js:babel-core/register --recursive './server/**/**/**/*-spec.js'"
我设法使其对我有用,也许您可以选择一些配置并将其应用于您的环境
我当前的软件包版本
"@babel/core": "^7.0.0", "@babel/register": "^7.0.0", "babel-plugin-istanbul": "^5.0.1", "chai": "^4.1.2", "mocha": "^5.2.0", "nyc": "^13.0.1"
更新/创建.babelrc
增加对伊斯坦布尔pluging
{“ plugins”:[“ istanbul”]}
为伊斯坦布尔创建一个配置文件: .nycrc
并粘贴此配置
{“ require”:[“ @ babel / register”],“ exclude”:[“ ** / *。{test,spec} .js”],“ all”:true,“ instrument”:false}
您可以在官方nyc存储库中检查更多选项
./node_modules/.bin/nyc mocha **/*.{test,spec}.js
要么
npx nyc mocha **/*.{test,spec}.js
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.