Skip to content

no-tautological-expect

Disallow supported assertions known to pass from literals or immutable scalar setup.

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);
});
Before — flagged A const setup assertion never observes the application
src/service.test.ts
it("works", () => {
const status = "ok";
expect(status).toBe("ok");
});
After — preferred A runtime scalar result remains a valid observation
src/service.test.ts
it("works", () => {
const status = serviceStatus();
expect(status).toBe("ok");
});