Tests that could not fail

Problem

Two tests in this build passed whatever the code did. A contrast test looped over a list of large-text colour pairs, and the list was empty, so the loop never ran and nothing was checked. A second test searched the built site for a sentence about repository access, and the site had never contained that sentence, so the search could only come back empty. Both showed green, and both made the suite look more thorough than it was.

Symptoms

What Didn't Work

Solution

Both tests were removed, along with the empty list and the plan lines that described them. Every colour pair already met the stricter contrast rule in the main list, so the large-text list had nothing left to guard. The second test guarded a sentence the site never had, so nothing real was lost.

A test that loops should also check that it looked at something:

const pages = builtPages()
expect(pages.length).toBeGreaterThan(0)
for (const page of pages) {
  // the real assertions
}

Why This Works

A test earns trust only by having failed once for the right reason. A loop over nothing and a search for text that was never there have the same flaw. Neither can reach a state where the assertion is false, so neither says anything about the code.

Prevention

Related Issues