StoicBuilder

HandbookVIII the PalaestraRegression tests

VIIIthe Palaestra, Test it

Regression tests

1 min readUpdated 28 November

In plain words

A regression test reproduces a bug that once happened, fails before the fix and passes after it, and stays in the suite so a later change can't bring the bug back unnoticed.

Where you see it

A team that signed up for Harbor's annual plan on 29 February 2024 was billed twice at renewal, in a year with no 29 February. The fix ships with a test named after the ticket that uses that exact date.

lib/billing/renewal.test.tsterminal
// HAR-412: annual plan started on 29 Feb 2024 was billed twice at renewaltest("renewal of a leap-day signup bills once (HAR-412)", () => { const invoices = renewals({ start: "2024-02-29", interval: "year", until: "2025-03-31" }); expect(invoices).toHaveLength(1); expect(invoices[0].date).toBe("2025-02-28");});
The ticket number tells the next reader why this oddly specific test exists.

What goes wrong

  1. Fixing before reproducing

    If the test never failed on the broken code, you don't know it captures the bug. Write it first, watch it fail, then fix.

  2. A test that misses the real input

    A test with an ordinary date passes before and after the fix. Use the exact input from the bug report, here 29 February, or the test guards nothing.

  3. Deleting it later because it looks odd

    Months on, someone sees a test about leap days and removes it as clutter. A comment with the ticket and one line on what went wrong keeps it where it belongs.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Before fixing this bug, write a test that reproduces it with the exact input from the report and show me it failing. Then fix the code, show the test passing, and name the test after the ticket with a one-line comment on what went wrong.

Quick check

Sign in to earn +10 XP for it

The agent fixes Harbor's double-billing bug and adds a test. You run the new test against the old code and it still passes. What does that mean?

Got a prompt that touches regression tests?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.