Skip to content

no-tautological-expect

Disallow supported literal-only assertions that are statically known to pass.

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.

Examples

Before — flagged Do not compare identical literals
src/add.test.ts
it("works", () => {
expect(true).toBe(true);
});
After — preferred Assert on a produced value
src/add.test.ts
it("adds", () => {
expect(add(1, 1)).toBe(2);
});