Closed felipemsantana closed 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!
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.
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()
.