# prefer-expect-resolves

Rule `jest/prefer-expect-resolves`. Prefer `await expect(...).resolves` over `expect(await ...)` syntax

- Source: jest
- Technologies: Testing
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1757 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `jest/prefer-expect-resolves` | no | safe | package `eslint-plugin-jest` | [docs](https://github.com/jest-community/eslint-plugin-jest/blob/v29.17.2/docs/rules/prefer-expect-resolves.md) |
| Oxlint | `jest/prefer-expect-resolves` | no | safe | plugin `jest`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/jest/prefer-expect-resolves.html) |

## Code examples

### Incorrect: the rule reports this

```js
it('passes', async () => {
  expect(await someValue()).toBe(true);
});

it('is true', async () => {
  const myPromise = Promise.resolve(true);

  expect(await myPromise).toBe(true);
});
```

### Correct: the rule accepts this

```js
it('passes', async () => {
  await expect(someValue()).resolves.toBe(true);
});

it('is true', async () => {
  const myPromise = Promise.resolve(true);

  await expect(myPromise).resolves.toBe(true);
});

it('errors', async () => {
  await expect(Promise.reject(new Error('oh noes!'))).rejects.toThrowError(
    'oh noes!',
  );
});
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import jest from "eslint-plugin-jest";

export default [
  {
    plugins: { jest },
    rules: {
      "jest/prefer-expect-resolves": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "jest"
  ],
  "rules": {
    "jest/prefer-expect-resolves": "error"
  }
}
```

## Related rules

- [vitest/prefer-expect-resolves](https://lintradar.dev/rules/vitest/prefer-expect-resolves.md): Enforce using `expect().resolves` over `expect(await ...)` syntax
- [jest/prefer-expect-assertions](https://lintradar.dev/rules/jest/prefer-expect-assertions.md): Suggest using `expect.assertions()` OR `expect.hasAssertions()`
- [jest/prefer-jest-mocked](https://lintradar.dev/rules/jest/prefer-jest-mocked.md): Prefer `jest.mocked()` over `fn as jest.Mock`
- [jest/prefer-ending-with-an-expect](https://lintradar.dev/rules/jest/prefer-ending-with-an-expect.md): Prefer having the last statement in a test be an assertion
- [jest/prefer-mock-promise-shorthand](https://lintradar.dev/rules/jest/prefer-mock-promise-shorthand.md): Prefer mock resolved/rejected shorthands for promises
- [jest/prefer-each](https://lintradar.dev/rules/jest/prefer-each.md): Prefer using `.each` rather than manual loops

---

Web page: https://lintradar.dev/rules/jest/prefer-expect-resolves. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
