visionmedia/mocha — pull request #506 by maraujop (2012-07-10 15:50:17+00:00)
Title: Adding HTML Coverage report for in-browser mode

Hi there,

I've been working on adding a Javascript coverage Reporter for CoverJS. It works with CoverJS instrumented code. This is what it looks like:

I've customized CoverJS standard output to mimic the one produced by `HTMLCov`. It is now an agnostic reporter, it doesn't follow Mocha reporter interface. So the way to use it is this:

```javascript
mocha.run(function () {
if (typeof window.__$coverObject !== 'undefined') {
var reporter = new HTMLReporter({ coverObject: window.__$coverObject });
reporter.report();

// Activate reporter.js scrolling stuff
onload();
}
});
```

For it to work body needs to contain:

And also you need to include `reporter.css` and `reporter.js` files. Both are modifications of already existing files in the project, done apart. The dependencies of this reporter are: jQuery, Backbone and underscore. jQuery would be very easy to remove.

It's not using any templating engine, so the HTML is embedded in the reporter a la CoverJS way. I think I read somwhere you were considering adding coverage for client reporter and not using jade, this might be a good starting point to do so.

Cheers,
Miguel