Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const test = n => {
if (n === 1) {
console.log(n)
} else if (n === 2) {
console.log(2)
} /* istanbul ignore next */ else if (1 === 2) {
console.log('math is broken')
} else {
console.log('n is some other thing')
}
}
test(1)
test(2)
test(3)
// gets 100% coverage, but STILL gets 100% coverage if test(3) removed
const test = n => {
if (n === 1) {
console.log(n)
} else if (n === 2) {
console.log(2)
} else /* istanbul ignore if */ if (1 === 2) {
console.log('math is broken')
} else {
console.log('n is some other thing')
}
}
test(1)
test(2)
test(3)
// does not get 100% coverage
const test = n => {
if (n === 1) {
console.log(n)
} else if (n === 2) {
console.log(2)
} else {
/* istanbul ignore if */
if (1 === 2) {
console.log('math is broken')
} else {
console.log('n is some other thing')
}
}
}
test(1)
test(2)
test(3)
// gets 100% coverage, fails 100% coverage if test(3) omitted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.