Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created September 26, 2019 06:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacs/987fc367e2422ba782de9298586ea5c7 to your computer and use it in GitHub Desktop.
Save isaacs/987fc367e2422ba782de9298586ea5c7 to your computer and use it in GitHub Desktop.
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