I'm using BluebirdJS promise library and I have .catch
that I can't mock that is why I can't cover it with my code coverage using istanbul.
.then(() => ....)
/* istanbul ignore next */ -> Does not work
.catch((err) => err) /// I want to ignore this
Is this possible with istanbul library?
This is the full code, my test can't reach the .catch
because it's always passing and I can't seem to another way to force mongoose to throw an error
const { payload } = request
const group = new LocationGroups(payload)
group.save()
.then(reply)
.catch((error) => reply(boomify(error)))
try {
} catch (err) /* istanbul ignore next */ {
}
In your case
group.save()
.then(reply)
.catch( /* istanbul ignore next */(error) => reply(boomify(error)))
Alternatively, you can wrap your catch in another block
try {
stuff()
} catch (err) {
/* istanbul ignore next */ {
console.error(err)
throw err
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With