After the snapshot went red
- Author
- Ethan Pier
The snapshot went red. Two hundred lines of HTML. I looked for three seconds and clicked update.
After that I lost interest in that kind of red. It says something changed. It does not say the new thing is right. Add an article, change a button label, and it yells. Yell often enough and you start rubber-stamping. Do that a few times and the file is only a signature you owe on a schedule.
This site’s tests later passed three hundred. I still run most of them. The ones that have actually stopped a bad change live elsewhere.
Article headers have to parse into a date, a title, tags. Miss the date and the page does not crash. It shows 1970. I would rather hear about that on my machine than ship a timestamp that looks like time travel.
Currents details too. Preload once marked unread stories as read. You will not catch that by glancing at a list — the state is “correct,” only early. We now test: preload must not write; a real open may write; unmounting must not sneak a write in afterward.
I am willing to be strict about security headers, which addresses should stay out of search indexes, what the feedback endpoint says when it is being hammered. A miss there is not ugly. It lets the wrong thing leave the building.
I almost never test class names. They move. Testing them is a memo with an expiry date. I do not time animations. I watch them. If a library lays out an image, that is its problem.
For a stretch I thought tests should always impersonate a user. Often they should: do the filters narrow the list, does empty search say empty, does copy change the label. Deep internal state makes that style brittle. Multi-step forms, canvas, key order — sometimes you have to lift out the middle beat. I do it rarely. Each time is an admission that the surface is getting hard to touch from outside.
I used to underestimate upkeep. A test that says “there are five articles” goes red on the sixth. Correct, and boring. I ask for properties now: are there articles; do they have addresses and dates. Content can grow. The pipe cannot run empty.
If I could talk to myself from six months ago I would say: write fewer tests you will update without flinching. When flinching is gone, they have already stopped protecting you.