UNPKG

eslint-plugin-jest-extended

Version:
44 lines (27 loc) • 1.04 kB
# Suggest using `toBeTrue()` (`prefer-to-be-true`) šŸ”§ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix). <!-- end auto-generated rule header --> 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: ```js expect(false).toBe(true); expect(wasSuccessful).toEqual(true); expect(fs.existsSync('/path/to/file')).toStrictEqual(true); ``` The following patterns are _not_ considered warnings: ```js 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 - [`jest-extended#toBeTrue` matcher](https://github.com/jest-community/jest-extended#tobetrue)