Several unit tests checking for errors would pass even if the error isn't thrown
alcidesqueiroz opened this issue · comments
Alcides Queiroz commented
Several unit tests that check if a given error has been thrown are using the following approach:
try {
await app.ready()
} catch (error) {
t.equal(error.message, 'The expected error message')
}
The problem here is that, without using t.plan
, these tests would pass even if the error wasn't thrown. And most tests using this pattern are not calling t.plan
. My suggestion is to replace these try/catch occurrences with t.rejects
, making the tests simpler and preventing these false positives.
FYI: @simoneb
Matteo Collina commented
This would be a great refactor!
Simone Busoli commented
Good catch