简体   繁体   English

浏览器单元测试的代码覆盖率

[英]Code Coverage for browser unit tests

We are writing unit tests for library where test cases are on client side. 我们正在为库编写单元测试,其中测试用例在客户端。 And we need to see code coverage for this library. 我们需要查看该库的代码覆盖率。 We have our own custom wrapper and we are not using nodejs on server side is on python. 我们有自己的自定义包装器,并且在服务器端不使用python上的nodejs。 Is there a suitable tool for this job? 有适合这项工作的工具吗?

If you want to test a clientside javascript library karma is a pretty good choice. 如果您想测试客户端javascript库, karma是一个不错的选择。 It is quite easy to learn and it gives you alot of functionality: 它很容易学习,并且为您提供了许多功能:

http://karma-runner.github.io/0.13/index.html http://karma-runner.github.io/0.13/index.html

Karma got a coverage report which gives you information about code coverage. Karma得到了一份coverage报告,其中提供了有关代码覆盖率的信息。 Combined with Jasmine you get a solid testing suite. Jasmine结合使用,您将获得一个可靠的测试套件。

This is now possible via Chrome dev-tools (As of Chrome 59). 现在可以通过Chrome开发者工具(自Chrome 59起)实现。 See this post for more information. 有关更多信息,请参见此帖子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM