> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# valid-expect-in-promise

[Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1)
## Configuration

| Preset                             | Configured Value |
| ---------------------------------- | ---------------- |
| ✅ rstestPlugin.configs.all         | `"warn"`         |
| ✅ rstestPlugin.configs.recommended | `"error"`        |


```ts title=rslint.config.ts
import { defineConfig, rstestPlugin } from '@rslint/core';

export default defineConfig([
  rstestPlugin.configs.recommended,
  {
    rules: {
      'rstest/valid-expect-in-promise': 'error',
    },
  },
]);
```

## Rule Details

Requires promise chains containing Rstest assertions to be returned or awaited. Otherwise the test can finish before the assertion runs or before its failure is reported.

Both Rstest `expect` and Chai `assert` calls are recognized. A promise chain may also be returned from the test callback.

## Incorrect

```ts
test('loads a user', () => {
  loadUser().then((user) => {
    expect(user.name).toBe('Ada');
  });
});
```

## Correct

```ts
test('loads a user', async () => {
  await loadUser().then((user) => {
    expect(user.name).toBe('Ada');
  });
});
```
