visionmedia/mocha — pull request #275 by kunklejr (2012-02-22 18:30:31+00:00)
Title: Add code coverage reporter for jscoverage

This is a simple reporter that extends the json reporter output with coverage data generated with jscoverage. Example output would look something like the following:

```json
{
"instrumentation": "node-jscoverage",
"sloc": 931,
"hits": 504,
"misses": 427,
"coverage": 54.13533834586466,
"files": [{
"filename": "mocha.js",
"coverage": 100,
"hits": 10,
"misses": 0,
"sloc": 10,
"source": {
"1": { "line": "require('covershot');", "coverage": "1" },
"2": { "line": "require('something-else';", "coverage": "1" }
} // remaining lines follow
}
}]
// normal json reporter output
}
```

If no jscoverage instrumented files are found it will output the summary level coverage data with default values (usually zeros). For example, when no instrumented files are present it would extend the normal json reporter output with the following:

```json
{
"instrumentation": "node-jscoverage",
"sloc": 0,
"hits": 0,
"misses": 0,
"coverage": 0,
"files": []
// normal json reporter output
}
```

Please note that this reporter doesn't change the existing json reporter in any way. It only uses the same output format as the basis for its output.

This pull request is related to issue #5.