Skip to content

Latest commit

 

History

History
43 lines (27 loc) · 1.02 KB

prefer-to-be-true.md

File metadata and controls

43 lines (27 loc) · 1.02 KB

Suggest using toBeTrue() (prefer-to-be-true)

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

For expecting a value to be true, jest-extended provides the toBeTrue matcher.

Rule details

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

The following patterns are considered warnings:

expect(false).toBe(true);

expect(wasSuccessful).toEqual(true);

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

The following patterns are not considered warnings:

expect(false).toBeTrue();

expect(wasSuccessful).toBeTrue();

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

test('is jest cool', () => {
  expect(isJestCool()).toBeTrue();
  expect(false).not.toBeTrue();
});

Further Reading