itay / node-cover

Native JavaScript Code Coverage
http://www.cover.io
165 stars 17 forks source link

using cover as a library #29

Closed defunctzombie closed 1 year ago

defunctzombie commented 12 years ago

Is there a good example (or even possible) to use cover as a library? The thinking would be to instrument it into a test suite (like mocha) so that the testing and coverage generation can happen all at once just by running the main test framework.

From my very limited understanding of cover, it works by intercepting require, which I think should mean that it could be dropped in to a nodejs app as a library?

defunctzombie commented 11 years ago

@itay are you still working on this project? Any thoughts on the above?

ogt commented 11 years ago

I would be also interested in the above.

Adding a unit test that checks the cover stats and confirms that all files are above a certain level of code coverage should be a simple thing to do. (similarly to what you do in the cli reporter to decide the red color of the row)

(I was thinking of adding a test like that ... it would fire when travis-ci kicks in... and make sure that no commit brings down the code coverage. So neat! )

itay commented 11 years ago

@ogt @shtylman I haven't had time, but I would more than welcome someone doing this. Happy to give either of you push access to the repo, and give some guidance on where to put things.

ogt commented 11 years ago

Thank you @itay. No need for push access. Let me look a bit at the code to see how easy/hard it is. I am using jshint as a model of how this should work from the caller's perspective.