Skip to content

Latest commit

 

History

History
43 lines (27 loc) · 1.03 KB

prefer-to-be-false.md

File metadata and controls

43 lines (27 loc) · 1.03 KB

Suggest using toBeFalse() (prefer-to-be-false)

🔧 This rule is automatically fixable by the --fix CLI option.

For expecting a value to be false, jest-extended provides the toBeFalse matcher.

Rule details

This rule triggers a warning if toBe(), toEqual() or toStrictEqual() is used to assert against the false literal.

The following patterns are considered warnings:

expect(true).toBe(false);

expect(wasSuccessful).toEqual(false);

expect(fs.existsSync('/path/to/file')).toStrictEqual(false);

The following patterns are not considered warnings:

expect(true).toBeFalse();

expect(wasSuccessful).toBeFalse();

expect(fs.existsSync('/path/to/file')).toBeFalse();

test('returns false', () => {
  expect(areWeThereYet()).toBeFalse();
  expect(true).not.toBeFalse();
});

Further Reading