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

34 lines
688 B
Markdown
Raw Normal View History

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