webhook/node_modules/eslint-plugin-jest/docs/rules/prefer-to-be-null.md
Joel Male 1ada95e04a
v2.0.0 (#12)
- Convert project to Javascript/Typescript
- Allow custom headers to be passed in (optional)
- Allow body to be optional
2020-08-26 10:52:47 +10:00

612 B

Suggest using toBeNull() (prefer-to-be-null)

In order to have a better failure message, toBeNull() should be used upon asserting expectations on null value.

Rule details

This rule triggers a warning if toBe(), toEqual() or toStrictEqual() is used to assert a null value.

expect(null).toBe(null);

This rule is enabled by default.

Default configuration

The following patterns are considered warnings:

expect(null).toBe(null);

expect(null).toEqual(null);

expect(null).toStrictEqual(null);

The following pattern is not warning:

expect(null).toBeNull();