> 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-conditional-expect

[Added in v0.8.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.0)
## 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-conditional-expect': 'error',
    },
  },
]);
```

## Rule Details

Disallows assertions that only run on some execution paths. A test can pass without checking anything when its assertion is skipped by a condition.

The rule recognizes `expect` from globals, imports, the local test context, Browser Mode, and Playwright integrations.

## Incorrect

```ts
test('returns the user name', () => {
  if (user) {
    expect(user.name).toBe('Ada');
  }
});
```

## Correct

```ts
test('returns the user name', () => {
  expect(user).toBeDefined();
  expect(user.name).toBe('Ada');
});
```
