We are planning to introduce JavaScript unit testing in our project and so far Jasmine appears to be one of the better BDD unit testing frameworks for JavaScript. Now I am wondering how can we monitor code coverage of our JavaScript code. Are there any tools/plugins that we could use? We are a Microsoft shop and use .NET/MVC 4.
the actual code coverage of those tests would reveal if the application is thoroughly stressed or not. for tests written using the famous jasmine test library, an easy way to have the coverage report is via istanbul and karma .
The easiest way to exclude code from code coverage analysis is to use ExcludeFromCodeCoverage attribute. This attribute tells tooling that class or some of its members are not planned to be covered with tests. EditFormModel class shown above can be left out from code coverage by simply adding the attribute.
There is the Istanbul code coverage tool. And, as there is a grunt plugin for Istanbul/Jasmine it should work with Jasmine.
A quick Googling turns up this blog post evaluating a bunch of options: Istanbul, Karma, Blanket.js, and JSCover.
For Rails, the jasmine-coverage (based on JSCoverage) gem gives you a Rake task that generates output in different formats
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With