github-pages-deploy-action/node_modules/eslint-plugin-jest/docs/rules/prefer-to-be-null.md

34 lines
610 B
Markdown
Raw Normal View History

2020-05-15 05:33:08 +08:00
# Suggest using `toBeNull()` (`prefer-to-be-null`)
2020-03-07 11:45:40 +08:00
In order to have a better failure message, `toBeNull()` should be used upon
asserting expections on null value.
## Rule details
This rule triggers a warning if `toBe()`, `toEqual()` or `toStrictEqual()` is
used to assert a null value.
```js
expect(null).toBe(null);
```
This rule is enabled by default.
### Default configuration
The following patterns are considered warnings:
```js
expect(null).toBe(null);
expect(null).toEqual(null);
expect(null).toStrictEqual(null);
```
The following pattern is not warning:
```js
expect(null).toBeNull();
```