Reputation: 604
How can we test else case for window. In My test cases it checks the if statement. But coverage shows else part not taken. How can we test that.
function sample(){
if(typeof window !== undefined){
doSomething()
}
}
Upvotes: 1
Views: 600
Reputation: 5226
You can use /* istanbul ignore else */
to ignore the else part coverage.
For your case,
function sample(){
/* istanbul ignore else */
if(typeof window !== undefined){
doSomething()
}
}
Check here for the other options.
Upvotes: 1