How to ignore branch coverage for missing 'else'

Is it possible to ignore marker E in the scope of the istanbul branch? I am using Jasmine + karma + Istanbul. Is it possible to enter E and get 100% branch coverage? Maybe a property that can be set in the karma config?

+7
istanbul
source share
2 answers

You can use /* istanbul ignore else*/ immediately before the if to ignore the missing else .

+10
source share

If you don't need comments all over the place, you can also set up another test where you actually hit this.

If you have something like this:

 _method: function () { if (this.foo === 'foo') { this.bar = false } } 

You just need to create a test where this.foo not equal to 'foo '.

+1
source share

All Articles