Question

We have an application written in coffee-script with node.js and are struggling to set up code coverage tools.

At the moment we have code-coverage up and running for the serverside with

  • coffeeCoverage
  • jscoverage
  • mocha

The front end unit tests are functions with the karma test runner and mocha, and working well. But I just can't seem to find a way to get the same kind of output from karma.

Here is the command being used for the serverside:

mocha --compilers coffee:coffee-script --require chai --reporter html-cov --recursive test/mocha > coverage.html

it would seem that because the front end is also in mocha and coffee-script we should be able to do the same thing there. But karma does not support the html-cov reporter, and that has left me at somewhat of a dead end.

The ideal path is that karma would run like normal in phantomjs and use the mocha html-cov reporter to output an html file. Does anyone know were to go from here?

Here is a portion of my Cake task for the serverside just for reference.

Was it helpful?

Solution

karma-coverage plugin uses Istanbul to instrument the source files and generate the coverage reports.

There's a pending issue to enable the same for coffee script too https://github.com/karma-runner/karma/issues/622

OTHER TIPS

I highly recommend switching from jscoverage to istanbul to calculate your code coverage. istanbul supports mocha (be sure to call _mocha) and is the default code coverage tool for karma. Details here: Code coverage with Mocha

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top