|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
710 bytes
|
| Line | |
|---|
| 1 | # Suggest using `toStrictEqual()` (`prefer-strict-equal`)
|
|---|
| 2 |
|
|---|
| 3 | `toStrictEqual` not only checks that two objects contain the same data but also
|
|---|
| 4 | that they have the same structure. It is common to expect objects to not only
|
|---|
| 5 | have identical values but also to have identical keys. A stricter equality will
|
|---|
| 6 | catch cases where two objects do not have identical keys.
|
|---|
| 7 |
|
|---|
| 8 | ## Rule details
|
|---|
| 9 |
|
|---|
| 10 | This rule triggers a warning if `toEqual()` is used to assert equality.
|
|---|
| 11 |
|
|---|
| 12 | ### Default configuration
|
|---|
| 13 |
|
|---|
| 14 | The following pattern is considered warning:
|
|---|
| 15 |
|
|---|
| 16 | ```js
|
|---|
| 17 | expect({ a: 'a', b: undefined }).toEqual({ a: 'a' }); // true
|
|---|
| 18 | ```
|
|---|
| 19 |
|
|---|
| 20 | The following pattern is not warning:
|
|---|
| 21 |
|
|---|
| 22 | ```js
|
|---|
| 23 | expect({ a: 'a', b: undefined }).toStrictEqual({ a: 'a' }); // false
|
|---|
| 24 | ```
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.