lumio
lumio

Reputation: 7575

Coverage drops when using babel

I stalled the decision of using babel but found, that it is necessary to write better code.

Before babel I used mocha and chai I started to test my code and reached up to a 100%. But since using it, my code coverage drops significantly (of course) as I only try to cover the resulting ES5 output.

So my question would be: How to test my source code without having a huge drop at my statistics.

Upvotes: 0

Views: 128

Answers (1)

loganfsmyth
loganfsmyth

Reputation: 161447

Generally the core issue with this, is that Babel has to insert code to cover all of the edge cases of the spec, but may not matter from the standpoint of coverage calculation.

The best approach currently would be to use https://github.com/istanbuljs/babel-plugin-istanbul to add the coverage tracking metadata to your original ES6 code, which means that even though Babel eventually converts it to ES5, the coverage will be about the ES6 code.

Upvotes: 1

Related Questions