[英]Mocha - Chai Unit Terst report generation - NodeJS
I am doing Unit Testing using Mocha chai
for sample NodeJS
project.我正在为示例
NodeJS
项目使用Mocha chai
进行单元测试。 Followed by the below reference.其次是下面的参考。
https://www.sitepoint.com/unit-test-javascript-mocha-chai/ https://www.sitepoint.com/unit-test-javascript-mocha-chai/
And I could run the tests successfully using terminal.我可以使用终端成功运行测试。 It is showing success/failure test status.
它显示成功/失败测试状态。 But, Test Report is not generated.
但是,不会生成测试报告。
I used the below command in terminal to run the test我在终端中使用了以下命令来运行测试
npm run test
How do I generate the report for the test.如何生成测试报告。
Try nyc ( https://www.npmjs.com/package/nyc ).试试纽约市( https://www.npmjs.com/package/nyc )。 Install as a dependency along with mocha and if your tests pass, this will generate the coverage report for you like a breeze.
与 mocha 一起作为依赖项安装,如果您的测试通过,这将为您轻松生成覆盖率报告。
I personally prefer using jest ( https://www.npmjs.com/package/jest ) instead of mocha/chai+nyc, it comes pre-equipped with reporting feature and pretty simple to use as well but it's your choice that matters here.我个人更喜欢使用 jest ( https://www.npmjs.com/package/jest ) 而不是 mocha/chai+nyc,它预先配备了报告功能并且使用起来也非常简单,但在这里重要的是您的选择.
You can have a look a similar question for more reading about nyc usage: Code coverage with Mocha您可以查看类似的问题以了解有关 nyc 使用的更多信息: Code coverage with Mocha
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.