Skip to content

jest/prefer-equality-matcher Style ​

What it does ​

Jest has built-in matchers for expecting equality, which allow for more readable tests and error messages if an expectation fails.

Example ​

javascript
// invalid
expect(x === 5).toBe(true);
expect(name === "Carl").not.toEqual(true);
expect(myObj !== thatObj).toStrictEqual(true);

// valid
expect(x).toBe(5);
expect(name).not.toEqual("Carl");
expect(myObj).toStrictEqual(thatObj);

References ​

Released under the MIT License.