jeffrifwald / babel-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
144 stars 23 forks source link

Add suggestion to replace istanbul in README file #54

Closed felipemsantana closed 8 years ago

felipemsantana commented 8 years ago

Added a suggestion to insert babel-istanbul module into require.cache as istanbul, so every module that requires istanbul gets babel-istanbul instead.

This solved a problem that occurred to me using karma-coverage, it was collecting the stats from babel compiled file, not from the source.

Before: 82.5% Statements 33/40 100% Branches 17/17 66.67% Functions 4/6 73.68% Lines 14/19 3 branches Ignored

After: 75% Statements 21/28 100% Branches 8/8 60% Functions 3/5 72.22% Lines 13/18

This could be a method, so you can call require('babel-istanbul').replaceIstanbul().

jeffrifwald commented 8 years ago

I feel like the solution to this problem is to create a karma package that uses babel-istanbul instead of istanbul. This seems too specialized of a case to address here. Thanks for the input though!

felipemsantana commented 8 years ago

This isn't a solution only to karma-coverage, this is generic solution, it could be any module that requires istanbul.

I mentioned it because I had problems and replacing istanbul in require.cache worked.