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

Discuss a different method to ignore foreign code #13

Closed Swatinem closed 9 years ago

Swatinem commented 9 years ago

My PR #12 fixes the case that functions that were not part of the code we not correctly ignored and were thus reported as uncovered.

While that particular issue is fixed now, the problem still exists that istanbul reports functions (and statements / branches / lines) as found, even though they are not present in my source file at all.

For example the code from PR #12 export {foo, bar} from "foobar" reports

Statements   : 100% ( 6/6 ), 2 ignored
Branches     : 100% ( 0/0 )
Functions    : 100% ( 2/2 ), 2 ignored
Lines        : 100% ( 1/1 )

And the one line that is reported is line 0, haha, so it means that it is not even highlighted in the html report. And for the statements, all 6 have skip: true set, but it shows only 2 ignored because those 2 are not covered (the return statements inside the ignored functions)

Swatinem commented 9 years ago

I’m not sure if its just the babel source maps that are strange for import/export, or if they are really supposed to be treated as declarations rather than statements? If that’s the case then a re-export only file really has zero statements/functions/lines worth covering.

Swatinem commented 9 years ago

I’m wondering if we could just ignore things that have line: 0 in the report step. That way those things should not show up in reports at all. I will try that tomorrow when I have some time :-)

jeffrifwald commented 9 years ago

I'm gonna go ahead and close this issue @Swatinem. We can add more specific issues as needed. Thanks for tackling this!