Skip to content

Files

Latest commit

 

History

History
21 lines (15 loc) · 557 Bytes

prefer-strict-equal.md

File metadata and controls

21 lines (15 loc) · 557 Bytes

Pattern: Use of loose equality

Issue: -

Description

Using toEqual() performs a loose equality check that may miss differences in undefined properties and types. toStrictEqual() provides more thorough comparison and clearer failure messages.

Examples

Example of incorrect code:

expect(value).toEqual({ a: 1 });
expect(result).toEqual({ name: "test", type: undefined });

Example of correct code:

expect(value).toStrictEqual({ a: 1 });
expect(result).toStrictEqual({ name: "test", type: undefined });