> 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.

# no-standalone-expect

[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/no-standalone-expect': 'error',
    },
  },
]);
```

## Rule Details

Disallows executable assertions outside a test callback. Assertions at module scope or directly in a suite run while the test file is registered, not as part of a test case.

Assertions inside helper functions are allowed because a test can call them. Static helpers such as `expect.any()` and `expect.extend()` are also allowed at module scope.

## Incorrect

```ts
describe('user service', () => {
  expect(createUser({ name: 'Ada' }).name).toBe('Ada');
});
```

## Correct

```ts
describe('user service', () => {
  test('creates a user', () => {
    expect(createUser({ name: 'Ada' }).name).toBe('Ada');
  });
});
```

## Options

```json
{
  "rstest/no-standalone-expect": [
    "error",
    { "additionalTestBlockFunctions": ["scenario"] }
  ]
}
```

| Option                         | Type       | Default | Description                                                      |
| ------------------------------ | ---------- | ------- | ---------------------------------------------------------------- |
| `additionalTestBlockFunctions` | `string[]` | `[]`    | Additional functions whose callbacks are treated as test blocks. |
