---
url: /docs/guide/usage/linter/rules/vitest/prefer-to-be-falsy.md
---

### What it does

This rule warns when `toBe(false)` is used with `expect` or `expectTypeOf`.
With `--fix-suggestions`, it will be replaced with `toBeFalsy()`.

### Why is this bad?

When testing for falsiness, `toBeFalsy()` expresses that intent directly.
Unlike `toBe(false)`, it also accepts non-boolean falsy values such as
`0`, `null`, and `undefined`. The replacement is a suggestion because
it changes which values pass the assertion.

### Examples

Examples of **incorrect** code for this rule:

```javascript
expect(foo).toBe(false);
expectTypeOf(foo).toBe(false);
```

Examples of **correct** code for this rule:

```javascript
expect(foo).toBeFalsy();
expectTypeOf(foo).toBeFalsy();
```

## How to use

## Version

This rule was added in v0.7.1.

## References
