Skip to content

Testing

Terminal window
task test # go test -race ./...
task check # formatting, lint, sqlc and tidy diffs, then the tests

Most packages have tests beside the code. The domain packages, such as internal/chores, are tested against a real SQLite database in a temporary folder, not mocks.

The HTTP tests in internal/server use a harness (newHarness in server_test.go). It runs the whole server on httptest, with:

  • a fresh database
  • a clock the test controls (h.advance(time.Hour))
  • a photos folder and a fake calendar feed (h.setICS(...))
  • helpers for each kind of device: h.setUp() runs first-run setup and returns the wall display, h.phone() a signed-in adult, and h.device() a stranger

Each device keeps its own cookies, so a test can tick a chore on the display and check what an adult’s phone sees. openEvents and waitEvent read the live event stream.

A test for a new board feature usually:

  1. Sets up a household and adds people and chores through the store or the admin forms.
  2. Acts as a device: posts the form or taps the htmx endpoint.
  3. Checks the HTML that comes back, and what the other devices see.

The Go tests check the HTML, but not how it looks or behaves. For any change to the board or admin, also try it in a real browser before opening a PR:

  • Use Chrome, driven headless by Playwright or Puppeteer, or by hand with the device toolbar.
  • Check at the wall iPad’s size, 1180×820 landscape, and on a phone.
  • Check light and dark mode.
  • Open two boards at once to see live updates, and check a locked display shows nothing personal.
  • For anything timed, such as a chore coming off at its cutoff, set it a minute or two ahead and watch.

Say what you checked, and at what size, in the PR’s Testing section. The screenshots on this site come from the same approach: scripts/screenshots/capture.mjs in the site repository seeds a demo household through the admin forms and drives Chrome with Puppeteer.