22

Is it possible to ignore the marker E in istanbul branch coverage?

I am using Jasmine+karma+Istanbul. Is there any possibility to ingore E and get 100% branch coverage?

Maybe a property that can be set in config?

Here is an example of the coverage results example of the error

Artur Grigio
  • 3,989
  • 6
  • 34
  • 56
rajesh madaswamy
  • 319
  • 3
  • 11

2 Answers2

30

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

Hawken MacKay Rives
  • 1,123
  • 1
  • 18
  • 25
Anobika
  • 353
  • 2
  • 6
0

If you don't want the comments all over the place you can also set up another test where you actually hit that else.

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 does not equal 'foo'.

Bill Criswell
  • 28,428
  • 3
  • 69
  • 65
  • yes, thanks.. but in some cases it's seems difficult to create a test ( i.e. promise catch(e) ..if { validation error.. } else { next(e) }. the else block is picking up any other kind of error and passing them to the next middleware error handler... appreciate any link to it –  Jun 25 '17 at 07:30