> 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-equality-matcher

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

| Preset                   | Configured Value |
| ------------------------ | ---------------- |
| ✅ jestPlugin.configs.all | `"error"`        |


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

export default defineConfig([
  jestPlugin.configs.recommended,
  {
    rules: {
      'jest/prefer-equality-matcher': 'error',
    },
  },
]);
```

## Rule Details

Suggest using the built-in equality matchers.

Jest has built-in matchers for expecting equality, which allow for more readable
tests and error messages if an expectation fails.

This rule checks for _strict_ equality checks (`===` and `!==`) in tests that
could be replaced with one of the following built-in equality matchers:

- `toBe`
- `toEqual`
- `toStrictEqual`

Fixes are provided as editor suggestions (one suggestion per matcher above).

Loose equality (`==` / `!=`) is not reported.

Examples of **incorrect** code for this rule:

```js
expect(x === 5).toBe(true);
expect(name === 'Carl').not.toEqual(true);
expect(myObj !== thatObj).toStrictEqual(true);
```

Examples of **correct** code for this rule:

```js
expect(x).toBe(5);
expect(name).not.toEqual('Carl');
expect(myObj).not.toStrictEqual(thatObj);
```

## Original Documentation

- [eslint-plugin-jest: prefer-equality-matcher](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/prefer-equality-matcher.md)
- [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/prefer-equality-matcher.ts)
