remy/nodemon — pull request #219 by matthew-andrews (2013-10-31 23:50:08+00:00)
Title: Implement Istanbul for code coverage metrics

So the implementation is not as clean as it ought to be (other test frameworks should work seamlessly with Istanbul but Mocha is a bit weird - see https://github.com/gotwarlost/istanbul/issues/44). In an ideal world the `npm test` command should look like:-

```
istanbul cover mocha --ui bdd --reporter spec test/**/*.test.js
```

To see the results locally just do:
```
git clone git@github.com:matthew-andrews/nodemon.git &&
cd nodemon &&
git checkout feature/json-config &&
npm install &&
npm test &&
open coverage/lcov-report/index.html
```

(You can customise the output format:- lcov for coveralls, cobertura for Jenkins, HTML for humans)

Additionally if you want to display a badge (like this: [![Coverage Status](https://coveralls.io/repos/ftlabs/fruitmachine/badge.png?branch=master)](https://coveralls.io/r/ftlabs/fruitmachine?branch=master)) we've been *quite* happy with coveralls.io - although the way it formats code could be a lot nicer... (For everything other than making the image, I prefer the html outputs that Istanbul creates out of the box)

This is how we implemented coveralls for fruitmachine*...
* https://github.com/ftlabs/fruitmachine/blob/master/.travis.yml#L3
* https://github.com/ftlabs/fruitmachine/blob/master/package.json#L55
* https://github.com/ftlabs/fruitmachine/blob/master/package.json#L32

\* Our view rendering engine, like Facebook's React but we were first. Maybe.

![coverage](https://f.cloud.github.com/assets/825088/1450864/c543fae4-4286-11e3-9157-205951beb7f1.png)

Also I would say for the record I don't think 100% code coverage is always worth aiming for... But that's a whole 'nother discussion. Hope this is useful.