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 786 forks source link

Coverage overlap? #669

Closed srinivas-os closed 8 years ago

srinivas-os commented 8 years ago

How does istanbul handle coverage overlap?

For instance, say I have a unit test, test1.js which covers 100% of src1.js. The next test, test2.js is actually intended to test src2.js but also ends up indirectly requiring and invoking part of src1.js. So when both tests complete, src1.js has been covered once completely (by test1.js), and part of it covered twice (by both tests).

In this case, what will be the final coverage of src1.js in the istanbul report? The behavior I see is, if I run istanbul on test1.js in isolation, src1.js shows 100% coverage. But if I run both tests, I see less coverage which I presume (maybe wrong) is the part covered by test2.js. What can be done to make sure istanbul only considers the max coverage?

srinivas-os commented 8 years ago

Apologies, this has nothing to do with overlapping coverage and is not an issue with istanbul. We were using node-jsx with "JS" extension which was clashing with istanbul's require hook and suppressing the coverage. Closing this.