gotwarlost / istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
8.7k stars 787 forks source link

istanbul API questions #710

Open still-dreaming-1 opened 7 years ago

still-dreaming-1 commented 7 years ago

I'm a bit confused about the API. I know it is a library that provides access to all the istanbul features. But does that mean you can have a script running, use that library to start code coverage, have some code after that that you want to get covered, and then stop the code coverage and generate reports using the library? Or is it more intended to be used how you would normally use istanbul without the library, like you have some code that uses the library to start istanbul and some script or tool at the same time with certain coverage options.

More specifically, I'm not sure what kind of object to pass to Collector.add(). The documentation just says something about it being a coverage object. I'm not sure if that means it should be a specific type of object that specifies how or what should be covered, or if it should be the actual object you want to get coverage information about. The documentation seems to frequently reference non-existent variables, so it is hard to understand.