# no-unneeded-async-expect-function

Rule `vitest/no-unneeded-async-expect-function`. Disallow unnecessary async function wrapper for expected promises

- Source: vitest
- Technologies: Testing
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 5.9M weekly downloads of presets that enable it
- Trend: +61.5% last quarter
- Rank: #1398 by reach, #699 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `vitest/no-unneeded-async-expect-function` | yes | safe | package `@vitest/eslint-plugin` | [docs](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-unneeded-async-expect-function.md) |
| Oxlint | `vitest/no-unneeded-async-expect-function` | no | safe | plugin `vitest`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-unneeded-async-expect-function.html) |

## Code examples

### Incorrect: the rule reports this

```js
it('wrong1', async () => {
  await expect(async () => {
    await doSomethingAsync()
  }).rejects.toThrow()
})

it('wrong2', async () => {
  await expect(async function () {
    await doSomethingAsync()
  }).rejects.toThrow()
})

it('wrong3', async () => {
  await expect(async () => await doSomethingAsync()).rejects.toThrow()
})
```

### Correct: the rule accepts this

```js
it('right1', async () => {
  await expect(doSomethingAsync()).rejects.toThrow()
})
```

Examples from the ESLint documentation.

## Enable it

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

```js
import vitest from "@vitest/eslint-plugin";

export default [
  {
    plugins: { vitest },
    rules: {
      "vitest/no-unneeded-async-expect-function": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "vitest"
  ],
  "rules": {
    "vitest/no-unneeded-async-expect-function": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Vitest recommended](https://lintradar.dev/presets/vitest-recommended.md) | ESLint | `@vitest/eslint-plugin` | 17 | 5.9M | +61.5% |

## Related rules

- [jest/no-unneeded-async-expect-function](https://lintradar.dev/rules/jest/no-unneeded-async-expect-function.md): Disallow unnecessary async function wrapper for expected promises
- [vitest/no-mocks-import](https://lintradar.dev/rules/vitest/no-mocks-import.md): Disallow importing from __mocks__ directory
- [vitest/prefer-called-exactly-once-with](https://lintradar.dev/rules/vitest/prefer-called-exactly-once-with.md): Prefer `toHaveBeenCalledExactlyOnceWith` over `toHaveBeenCalledOnce` and `toHaveBeenCalledWith`
- [vitest/no-interpolation-in-snapshots](https://lintradar.dev/rules/vitest/no-interpolation-in-snapshots.md): Disallow string interpolation in snapshots
- [vitest/require-local-test-context-for-concurrent-snapshots](https://lintradar.dev/rules/vitest/require-local-test-context-for-concurrent-snapshots.md): Require local Test Context for concurrent snapshot tests
- [vitest/no-commented-out-tests](https://lintradar.dev/rules/vitest/no-commented-out-tests.md): Disallow commented out tests

---

Web page: https://lintradar.dev/rules/vitest/no-unneeded-async-expect-function. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
