Skip to content

jest/prefer-strict-equal Style

🛠️ An auto-fix is available for this rule.

What it does

This rule triggers a warning if toEqual() is used to assert equality.

Example

javascript
// invalid
expect({ a: "a", b: undefined }).toEqual({ a: "a" });

// valid
expect({ a: "a", b: undefined }).toStrictEqual({ a: "a" });

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny jest/prefer-strict-equal --jest-plugin
json
{
  "plugins": ["jest"],
  "rules": {
    "jest/prefer-strict-equal": "error"
  }
}

References

Released under the MIT License.