Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 1.11 KB

prefer-strict-equal.md

File metadata and controls

34 lines (22 loc) · 1.11 KB

Suggest using toStrictEqual() (prefer-strict-equal)

💼 This rule is enabled in the following configs: all.

💡 This rule is manually fixable by editor suggestions.

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.

Rule Details

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

Default configuration

The following pattern is considered warning:

expect({ a: 'a', b: undefined }).toEqual({ a: 'a' }); // true

The following pattern is not warning:

expect({ a: 'a', b: undefined }).toStrictEqual({ a: 'a' }); // false