arian/CoverJS — pull request #3 by maraujop (2012-07-10 15:18:51+00:00)
Title: Adding an HTML reporter for in browser reporting

Hi there,

I've been working on porting CoverJS reporters from nodejs to javascript using Backbone. It doesn't fully mimic the inheritance hierarchy, but it fully works.

I'm sending a reporter that uses Backbone and underscore/lodash for rendering an HTML report in a `

`. It also renders a menu of files in a `

`. Coverage is rendered in a table, not within `pre` tags as nodejs reporters from CoverJS.

It would be very easy to use the same code as in nodejs reporters `report` method. I think it's a good idea to have an example of a Javascript reporter, that can handle the `coverObject` and render a report in a browser.

This Reporter can be adapted to be used with any testing framework such as Jasmine, QUnit or Mocha. This one here, produces HTML to be used with some Mocha CSS and js files, for better usability.

The main difference, is the way `FileReporter.report` works. I'm not modifying `codez` array within the loop using `splice` and the jumping. I find it quite hard to customize and follow. So I'm following a different strategy, that allowed me to produce table rows easier.

I'm willing to discuss anything about this pull request. I'm going to submit this reporter to Mocha project, with the different JS files and CSS files. It will probably need some adaptation to turn it into a Mocha reporter.

Thanks, cheers
Miguel