prefer-expect-resolves
Configuration
rslint.config.ts
Rule Details
Prefer await expect(promise).resolves.<matcher> over
expect(await promise).<matcher> when asserting on a resolved promise value.
If the promise rejects, expect(await promise) throws before Jest can run the
matcher, so the failure looks like an unhandled rejection rather than a test
assertion. The .resolves modifier keeps failures inside Jest's matcher
pipeline and mirrors .rejects, which has no equivalent await-inside-expect
form.
This rule reports await used as an argument to expect() (including renamed
expect bindings from @jest/globals). It is fixable.
Examples of incorrect code for this rule:
Examples of correct code for this rule: