# prefer-equality-matcher

Rule `jest/prefer-equality-matcher`. Suggest using the built-in equality matchers

- Source: jest
- Technologies: Testing
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1663 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `jest/prefer-equality-matcher` | no | suggestion | package `eslint-plugin-jest` | [docs](https://github.com/jest-community/eslint-plugin-jest/blob/v29.17.2/docs/rules/prefer-equality-matcher.md) |
| Oxlint | `jest/prefer-equality-matcher` | no | safe | plugin `jest`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/jest/prefer-equality-matcher.html) |
| Biome | `nursery/useExpectEqualityMatcher` | no | unsafe | group nursery, since 2.6.9 | [docs](https://biomejs.dev/linter/rules/use-expect-equality-matcher/) |

## Code examples

### Incorrect: the rule reports this

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

### Correct: the rule accepts this

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

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import jest from "eslint-plugin-jest";

export default [
  {
    plugins: { jest },
    rules: {
      "jest/prefer-equality-matcher": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "jest"
  ],
  "rules": {
    "jest/prefer-equality-matcher": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "useExpectEqualityMatcher": "error"
      }
    }
  }
}
```

## Related rules

- [vitest/prefer-equality-matcher](https://lintradar.dev/rules/vitest/prefer-equality-matcher.md): Enforce using the built-in equality matchers
- [jest/prefer-called-with](https://lintradar.dev/rules/jest/prefer-called-with.md): Suggest using `toHaveBeenCalledWith()`
- [jest/prefer-hooks-in-order](https://lintradar.dev/rules/jest/prefer-hooks-in-order.md): Prefer having hooks in a consistent order
- [jest/no-hooks](https://lintradar.dev/rules/jest/no-hooks.md): Disallow setup and teardown hooks
- [jest/prefer-hooks-on-top](https://lintradar.dev/rules/jest/prefer-hooks-on-top.md): Suggest having hooks before any test cases
- [jest/max-nested-describe](https://lintradar.dev/rules/jest/max-nested-describe.md): Enforces a maximum depth to nested describe calls

---

Web page: https://lintradar.dev/rules/jest/prefer-equality-matcher. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
