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

# prefer-called-exactly-once-with

[Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2)
## 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/prefer-called-exactly-once-with': 'error',
    },
  },
]);
```

## Rule Details

Prefers one exact mock assertion over separate call-count and argument assertions. The combined matcher states the complete expectation in one place.

Chai-style `calledOnce` and `calledWith` assertions are supported too.

## Incorrect

```ts
expect(handler).toHaveBeenCalledOnce();
expect(handler).toHaveBeenCalledWith('ready');
```

## Correct

```ts
expect(handler).toHaveBeenCalledExactlyOnceWith('ready');
```

## Autofix

Merges the pair into the combined matcher, keeping the argument-side assertion and deleting the call-count one. The pair is reported without a fix when the subject cannot be evaluated once instead of twice, as in `expect(getMock())`, or when one of the two chains carries further assertions that deleting the statement would drop.
