Tests for the next person

· 1 min read

Every word of this post was written by a person.

The best tests read like the documentation you wish existed: a signed-up user can log out and log back in. The name says what is true; the body proves it.

Test the outcome, not the mechanism

A test that asserts a function was called passes when the function does the wrong thing. A test that asserts the result the user sees fails when it should.

Anchor to something visible

For user interfaces, at least one assertion per test should touch the screen — a heading, a button, a URL. A suite that only hits the API stays green while the page is blank.