node.js - 摩卡-柴覆盖范围未知
问题描述
大家好,我正在尝试获取 mocha chai 单元测试覆盖率报告。
我得到了测试结果通过。
还将覆盖范围生成为 html,但显示未知。请看下图。
Package.json
在脚本中添加了以下配置。
"scripts": {
"test": "mocha",
"test-with-coverage": "nyc --reporter=html mocha"
},
并使用以下命令运行测试。
npm run test-with-coverage
编辑: 将报告更改为文本时,在终端中获取以下报告。
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 0 | 0 | 0 | 0 |
----------|---------|----------|---------|---------|-------------------
解决方案
请尝试使用以下命令,
nyc -x \"**/tests/**\" --reporter=cobertura --reporter=html mocha 'your test folder path'
推荐阅读
- java - 一对多 Spring 数据 JDBC
- google-play - google play 上的同一个包。可能吗?
- angularjs - Symfony API + AngularJS 响应非常慢
- docusignapi - DocuSign Api 在生产中创建信封
- haskell - 如何实现这个 Haskell 函数?
- python - 从 xarray 数据集中的闰年中删除闰日
- python - 无法导入模块“lambda_function”:没有名为“stomp”的模块
- xamarin - 从 Xamarin.iOS 中的 NSUrl 获取文件名的最简单方法是什么?
- regex - python 正则表达式搜索限制
- python - Python:计算矩阵内核时的计算精度