node-jscoverage with vows.js
For Migrii, we're using Vows.js to run server side tests of our node.js code. Vows.js runs code coverage if node-jscoverage is installed. Node-jscoverage is used by a few node.js based testing frameworks, so I won't get into the configuration/installation of Vows.js.
It took me a while to get it working, so I thought I'd share the steps:
1. Clone the node-jscoverage repo on Github:
$ git clone https://github.com/visionmedia/node-jscoverage.git
2. Despite what the readme says,1 you need to run the following command to install:
$ ./configure && make && make install
3. Despite what you read on other sites, run the following command to instrument your code (use jscoverage, not node-jscoverage).
$ jscoverage [source] [destination]
4. I found it useful to follow the steps in this page to require the instrumented code in the tests.
5. Run your test command, with the coverage flags, and everything should work
$ vows test.js --cover-html
Easy, but the omissions/errors in the commands wasted a few hours of my time.
Links:
1. https://github.com/visionmedia/node-jscoverage/pull/16













