Open cstickel opened 6 years ago
@mixer2 Hey there — yep, working around Istanbul (coverage in general) is pretty tricky. It’s something I’d love to support but have been unable to find the time to explore how (and if) it can be done. Sorry for the inconvenience.
@mixer2, @plasticine, the same in my project. We are using: Karma + Webpack + Istanbul Instrumenter Loader + coverageInstunbulReporter.
We are facing a pretty similar issue. Lets say that we have:
import something from './something'.
const doSomething = () => {
const a = 50;
const b = a + 100;
something(b);
}
export default doSomething;
Test spec would be:
import somethingInjector from 'inject-loader!./something';
describe('something', () => {
it('should do something', () => {
const iSomething = somethingInjector(
'./something': () => console.log('mocked'),
).default;
iSomething();
})
});
The issue is that coverage report shows that original doSomething()
function is completely uncovered.
I tried inject-loader with Typescript and Istanbul coverage.
For the code:
The inject-loader adds a logical or-expression. The result looks like:
If the depedency is mocked in all tests and the actual module is never used, the right side of the or-expression is never executed. This results in an uncovered branch in the coverage report.