【问题标题】:nodejs - How to check which portion of code is tested with unit tests?nodejs - 如何使用单元测试检查代码的哪一部分?
【发布时间】:2018-12-24 23:12:16
【问题描述】:

我正在使用tapeistanbul 在我的Node.js 项目中编写单元测试,结果如下:

Statements   : 93.04% ( 107/115 )
Branches     : 86.84% ( 33/38 )
Functions    : 90% ( 27/30 )
Lines        : 93.86% ( 107/114 )

有没有办法找出哪些语句、函数或代码部分未经测试?

【问题讨论】:

    标签: node.js unit-testing code-coverage istanbul node.js-tape


    【解决方案1】:

    根据文档,您应该在 ./coverage 下找到完整的 html 报告,逐行覆盖:

    这应该在./coverage下产生coverage.jsonlcov.infolcov-report/*html 此工具生成的代码覆盖率报告示例(针对此工具!):HTML reports

    文档:https://github.com/gotwarlost/istanbul#getting-started

    【讨论】:

    • istanbul 没有在覆盖文件夹中生成 .html 文件,因为我使用 istanbul cover --root ./server --report cobertura ./server/all-tests.js 而不是 --report html 参数调用脚本。谢谢:D
    猜你喜欢
    • 1970-01-01
    • 2018-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多