mercurius-js / mercurius

Implement GraphQL servers and gateways with Fastify

Home Page:https://mercurius.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Several unit tests checking for errors would pass even if the error isn't thrown

alcidesqueiroz opened this issue · comments

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

This would be a great refactor!

Good catch