2

I wanna gauge unit test coverage for Javascript.

jscoverage is one of the most useful tool. However, jscoverage can only gauges which the code pass or not on unit test. I wanna gauge coverage including logic.

How should I gauge unit test coverage for JS ?

  • Could you give some specific code examples that should be tested for unit coverage with something more powerful than `jscoverage`? – raina77ow Sep 07 '12 at 09:04
  • For Example, in case of "If Statement", I wanna gauge coverage of both true and false. jscoverage is 100% in case of either true or false. – user1654140 Sep 07 '12 at 09:15
  • Erm... did you check the jscoverage doc on `#JSCOVERAGE_IF` directive, which is actually used to _prevent_ collecting coverage statistics for only _one_ branch of the `if` condition? – raina77ow Sep 07 '12 at 09:21

1 Answers1

0

BlanketJS is a fantastic code coverage tool that works well with QUnit. I've been using it for about a year now.

For larger projects, I also have QUnit and Blanket integrated with Grunt so I can run my tests, and check my code coverage thresholds from the command line, as well as CI solutions like TravisCI.

There was no existing Grunt plugin that fit my needs, so I wound up writing my own Grunt plugin. The plugin supports "enforcement" of a minimum threshold, or else the Grunt task fails.

I wrote a blog post with all the details here: http://www.geekdave.com/2013/07/20/code-coverage-enforcement-for-qunit-using-grunt-and-blanket/

Dave Cadwallader
  • 1,751
  • 12
  • 10