-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[new rule] prefer await expect(...).resolves
#803
Comments
@SimenB I just came across an interesting difference that I didn't realise with the stack traces. This code:
Gives me this stacktrace:
Whereas the
While the first is (imo) nicer as it's the test failing rather than throwing a raw error, its stacktrace doesn't point me to where the error was actually thrown - instead it just points me at Is this known on the |
🎉 This issue has been resolved in version 24.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This issue has been resolved in version 25.0.0-next.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Pretty much the opposite to the now-deprecated
no-expect-resolves
: prefer doingawait expect(...).resolves
overexpect(await ...)
as it gives a better failure message.With
resolves
, if the promise rejects it'll fail the assertion, giving you an error on the lines ofexpected promise to resolve but it rejected with ...
.expect(await ...)
however means that the rejection will be thrown "outside" of theexpect
, giving you a more generic "test thrown an unexpected error" message.This also affected the behaviour of
expect.hasAssertions
& co, as withresolves
you'll be hitting an assertion which fails, which is considered a "passin the eyes of
hasAssertions`.I think
prefer-expect-resolves
could be a good name for this new rule.The text was updated successfully, but these errors were encountered: