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

Weird HTML reports with istanbul@0.4.3 / babel-istanbul and ternary operators #608

Open silkentrance opened 8 years ago

silkentrance commented 8 years ago

Please see https://github.com/jmcriffey/babel-istanbul/issues/56 for more information on this.

jeffrifwald commented 8 years ago

I think https://github.com/gotwarlost/istanbul/issues/557 may be either related or the same issue.

silkentrance commented 8 years ago

Again having this issue with a different ternary operator

image

mynameistechno commented 8 years ago

Is there a work around for this?

silkentrance commented 8 years ago

@mynameistechno the only work around for this is to get rid of the ternary operator and make it an if-then-else statement...

ltahilra commented 8 years ago

I'm getting the same issue, the code coverage with ternary operator seems like this:

with ternary operator

However if you view page source you get the following: t</span>his.mode = window ? 'WebBrowser' : <span class="branch-1 cbranch-no" title="branch not covered" >'server'; The </span> closing tag should ​not​ precede the open <span> tag. Seems the html is not rendered properly.

Adding a line break seems like one of the work around for this:

with line break
saschagehlich commented 8 years ago

Same happens here:

screenshot 2016-07-19 11 09 51

I guess HTML rendering is okay, but the coverage.raw.json is wrong?

gotwarlost commented 8 years ago

AFAIK, all this is happens because of https://phabricator.babeljs.io/T7453 - in essence, babel is producing incorrect source maps.