| Server IP : 185.208.173.17 / Your IP : 87.236.161.98 Web Server : Microsoft-IIS/10.0 System : Windows NT SRV8576125506 10.0 build 26100 (Windows Server 2016) AMD64 User : IUSR ( 0) PHP Version : 7.4.13 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/parsmega.nuxt/node_modules/eslint-plugin-jest/docs/rules/ |
Upload File : |
# Disallow using `toBeTruthy()` & `toBeFalsy()` (`no-truthy-falsy`)
## Deprecated
This rule has been deprecated in favor of
[`no-restricted-matchers`](no-restricted-matchers.md) with the following config:
```json
{
"rules": {
"jest/no-restricted-matchers": [
"error",
{
"toBeTruthy": "Avoid `toBeTruthy`",
"toBeFalsy": "Avoid `toBeFalsy`"
}
]
}
}
```
---
Tests against boolean values should assert true or false. Asserting `toBeTruthy`
or `toBeFalsy` matches non-boolean values as well and encourages weaker tests.
For example, `expect(someBoolean).toBeFalsy()` passes when
`someBoolean === null`, and when `someBoolean === false`.
Similarly, `expect(someBoolean).toBeTruthy()` passes when `someBoolean === []`,
and when `someBoolean === 'false'` (note that `'false'` is a string).
## Rule details
This rule triggers a warning if `toBeTruthy()` or `toBeFalsy()` are used.
This rule is disabled by default.
### Default configuration
The following patterns are considered warnings:
```js
expect(someValue).toBeTruthy();
expect(someValue).toBeFalsy();
```
The following patterns are not considered warnings:
```js
expect(someValue).toBe(true);
expect(someValue).toBe(false);
```