TypeScript · testing
no-tautological-expect
eslint:no-tautological-expect Disallow an assertion whose operands are all literals; its outcome is fixed before the code runs, so it can never fail.
- Default
- error
- Fix
- none
- Languages
- typescript
Why
An assertion determined entirely by literals does not observe the code under test and can keep passing after that code is removed.
Fix
Assert on a value produced by the behavior under test, or remove the assertion.
Before / after
Executed by this rule’s unit tests.
Before
Do not compare identical literals
it('works', () => { expect(true).toBe(true); }); After
Assert on a produced value
it('adds', () => { expect(add(1, 1)).toBe(2); }); Limits
- Only direct supported `expect` matcher calls in recognized test files are inspected.
Message IDs
tautologicalComparisontautologicalMatcher