eslint-plugin-jest
Version:
ESLint rules for Jest
28 lines (18 loc) ⢠852 B
Markdown
š” This rule is manually fixable by
[](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).
<!-- end auto-generated rule header -->
`toStrictEqual` not only checks that two objects contain the same data but also
that they have the same structure. It is common to expect objects to not only
have identical values but also to have identical keys. A stricter equality will
catch cases where two objects do not have identical keys.
This rule triggers a warning if `toEqual()` is used to assert equality.
The following pattern is considered warning:
```js
expect({ a: 'a', b: undefined }).toEqual({ a: 'a' }); // true
```
The following pattern is not warning:
```js
expect({ a: 'a', b: undefined }).toStrictEqual({ a: 'a' }); // false
```