Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
7,631 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Suggest using `toContain()` (prefer-to-contain) | ||
|
||
In order to have a better failure message, `toContain()` should be used upon | ||
asserting expectations on an array containing an object. | ||
|
||
## Rule details | ||
|
||
This rule triggers a warning if `toBe()` or `isEqual()` is used to assert object | ||
inclusion in an array | ||
|
||
```js | ||
expect(a.includes(b)).toBe(true); | ||
``` | ||
|
||
```js | ||
expect(a.includes(b)).toBe(false); | ||
``` | ||
|
||
### Default configuration | ||
|
||
The following patterns are considered a warning: | ||
|
||
```js | ||
expect(a.includes(b)).toBe(true); | ||
``` | ||
|
||
```js | ||
expect(a.includes(b)).toBe(false); | ||
``` | ||
|
||
The following patterns are not a warning: | ||
|
||
```js | ||
expect(a).toContain(b); | ||
``` | ||
|
||
```js | ||
expect(a).toContain(b); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.