source: frontend/node_modules/eslint-plugin-jest/docs/rules/prefer-equality-matcher.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks ago

Fix frontend appearance

  • Property mode set to 100644
File size: 735 bytes
RevLine 
[9af201e]1# Suggest using the built-in equality matchers (`prefer-equality-matcher`)
2
3Jest has built-in matchers for expecting equality which allow for more readable
4tests and error messages if an expectation fails.
5
6## Rule details
7
8This rule checks for _strict_ equality checks (`===` & `!==`) in tests that
9could be replaced with one of the following built-in equality matchers:
10
11- `toBe`
12- `toEqual`
13- `toStrictEqual`
14
15Examples of **incorrect** code for this rule:
16
17```js
18expect(x === 5).toBe(true);
19expect(name === 'Carl').not.toEqual(true);
20expect(myObj !== thatObj).toStrictEqual(true);
21```
22
23Examples of **correct** code for this rule:
24
25```js
26expect(x).toBe(5);
27expect(name).not.toEqual('Carl');
28expect(myObj).toStrictEqual(thatObj);
29```
Note: See TracBrowser for help on using the repository browser.