An assertion compares a value with itself, so it always passes

tx0/ts:assertion-compares-value-to-itselfdefaultwarningmaintainability/testsdepth fastbug

What it finds

expect(a).toBe(a) or assert.equal(x, x) passes whatever the value is. One of the two sides was meant to be something else, usually the expected value.

Reported are expect(x) with toBe, toEqual or toStrictEqual of the same expression, and assert comparisons of the same expression, when the expression calls nothing.

From the rule's source, assertion_compares_value_to_itself.rs.

Example from the rule's tests
it("keeps the name", () => {  const user = { name: "a" };  expect(user.name).toBe(user.name);tx0 reports: this assertion compares a value with itself  expect(user.name).toBe("a");});
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:assertion-compares-value-to-itself" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:assertion-compares-value-to-itself] reason="..."

tx0 explain tx0/ts:assertion-compares-value-to-itself shows the same in the terminal. Found a false positive? Report it.