A check only counts once you've seen it fail
A test you have never seen fail proves nothing. Two cases where a check stayed green when it should have fired, and how to put your own tests to the proof.
TL;DR
Never trust a test you haven't seen fail. A green test only tells you it didn't fire. Whether it can fire at all you only know once you've watched it fail. So you plant the bug it should catch, run only that test and revert the change. That takes a few minutes. In my repo it exposed a guard that would have missed a whole kind of table, and tests that stayed green on broken data.
The broken probe that stayed green
Monday, 26 October. An AI agent has just written me a new guard, a test that enforces one rule across the whole repo. It should keep two tables with the same header row off a single page. On my website every table gets a scrollable region whose name comes from its header row, for example "Table: Stage; Name, scrolls sideways". Two identical header rows give two identical names, and the accessibility check (axe) reports two regions with the same name.
The test is green. Then the step I never skip: a probe file with exactly that bug, two tables with the same header row. The test stays green.
The cause was the regular expression for the separator row under the header. It expected dashes like ---. GFM Markdown tables also allow colons there for alignment, such as :-- or --:. The guard didn't recognise such tables as tables at all, so it never checked them. Today two of the 14 separator rows in my blog content carry such a colon (counted with grep over src/content). Both belong to one table, in German and English. It landed two days after the guard.
Once the expression was fixed, the probe turned red. Without the probe, the guard would have waved exactly that table through, and I would have trusted it.
What watching it fail means
The rule is already in How I Keep Thinking Critically When AI Agents Do the Work: a new check only counts once I've deliberately seen it fail.
In practice: you reproduce the bug the test should protect against. You run only that one test and watch it fail. Then you revert the change and watch it pass again. My repo's test rules have this as a separate item: mutate, the test must fail, revert, the test must pass. If it stays green under the mutation, it gets sharpened or deleted.
It's cheap. Usually it's one changed line and a single test run.
Green because both sides are equally broken
The second case is from August. My sitemap writes a modification date for every page. The dates come from files I maintain by hand. A typo there gives an "Invalid Date" in JavaScript. Back then, generating the sitemap threw, and the sitemap returned a 500.
The other tests checked the date like this: expected value equals new Date(source), and the result is an instance of Date. Both stay green on a typo. Vitest treats two invalid dates as equal, and an invalid date is still a Date. If the expected value is built from the same broken source, both sides carry the same error.
Watching it fail showed it: a date was set to 2026-13-99 for the test. The new sweep with Number.isNaN(date.getTime()) failed, the old comparisons stayed green. It still holds in Vitest 5.0.
The new sweep has a limit too: in Node, new Date('2026-02-30') is a valid date, 2 March. Number.isNaN doesn't catch that typo.
Red first, then the fix
On 6 November it was about one line in my llms.txt, the file for AI crawlers. Next to the hackathon result it also listed the size of the worldwide field of participants. That reads like a win against the whole field, which isn't what happened.
The new test checks that this line no longer contains the worldwide field, in German and in English. Before the line was changed, it ran against the old version. Both cases failed. Then came the change, then green. The test first checks that the line is there and names the hub. Otherwise "does not contain" would also pass if the line were missing altogether.
The guard for my sitemap went the same way. It blocks two variants of the same trap: the sitemap as sitemap.ts or as sitemap.xml/route.ts. Both were planted on purpose and seen failing. The story is in Merged is not live.
When it matters most
Watching a test fail pays off most for three kinds of checks.
Guards against regressions nobody watches. The table guard protects against a bug I'd never see on the page. If a guard like that stays silent, nobody notices.
Checks built on regular expressions. If the test checks "must not occur", an expression that never matches is always green. From the outside that looks like an expression that works.
Tests written by an AI agent. All four checks in this post come from commits I wrote together with Claude. An agent works towards green tests. A test that can't fail is the shortest way there, and in the report it looks just as green as a good one. So I put it in the brief: "Before you report a new test as done, plant the bug, show me the red output, revert it, show me the green one. Note in the commit message which change made it fail."
How to do it
- Write down in one sentence which bug the test should catch.
- Plant exactly that bug. In the code or in a probe file, not in the test itself.
- Run only that test, for example
pnpm exec vitest run tests/my.test.ts. - Read the failure message. It has to fail for the right reason, not because of a typo in the probe.
- Revert the change and run it again. Now it has to pass.
- Note in the test comment or the commit message which change made it fail.
- If you can, keep the probe as a test case of its own. That's a small fixture with the bug, and the test must fail on it. Then the proof runs in CI on every push, not just once on your machine.
If it stays green in step 3, you've found something. Then you sharpen the test or delete it. A green test that checks nothing is worse than none, because it reassures you.
Common questions
What does "watch it fail" mean in practice?
You deliberately plant the bug a test is meant to catch and run only that test. If it fails, and for the right reason, you revert the change and watch it pass again. Only then do you know it detects the bug.
Why does a date comparison with toEqual pass on broken dates?
Vitest treats two invalid dates as equal. If the expected value comes from the same broken source, both sides hold an Invalid Date and the comparison passes. Only Number.isNaN(date.getTime()) separates valid from invalid dates. A more readable form is expect(date.getTime()).not.toBeNaN().
Is this the same as mutation testing?
It's the manual version of it, for a single test. Mutation testing tools change the code automatically in many places, StrykerJS for example in JavaScript and TypeScript. For a new guard, one targeted change that reproduces exactly the bug it should protect against is enough.