摩卡咖啡覆盖率未知

时间:2020-04-15 02:04:17

标签: node.js unit-testing mocha code-coverage chai

您好,我正在尝试获取“摩卡咖啡”单元测试覆盖率报告。

我正在通过测试结果。

也将coverage生成为html,但显示Unknown。请参见下图。

enter image description here

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 |                   
----------|---------|----------|---------|---------|-------------------

1 个答案:

答案 0 :(得分:1)

请尝试使用以下命令,

Class Employee () {
 Private name;
 Private id;
}