Lesson 8 of 110 of 6 steps

Lesson 8 · about 25 minutes

Test it before it goes live

Before anything goes live, your agent checks it the way you would: it clicks through the whole app in a real browser, pretends to be two people, turns the signal off, and shows you pictures. Only then does it ask if it can put it live.

Unit tests for the logic, API checks, a full Playwright click-through at phone size with two people and offline, screenshots opened for you, then a deploy you approve.

Unit tests for the logic with node --test, and API tests against wrangler dev. Then a Playwright click-through at phone size that signs in as two people, goes offline, fails on any page error and checks nothing scrolls sideways. All of it runs before every deploy.

How much have you built before?
This lesson's wording changes to match.
FreeRuns before every release
$ npm test✓ sums and edge cases$ npm run check✓ sign up, log, edit, undo, delete✓ two people see the same log✓ no signal, then it syncs

An example of what a run looks like.

What you'll make

  • Tests that check the sums your app does
  • A click-through of the whole app in a real browser
  • Screenshots of every change, opened for you

You'll need: an app with a few screens (lessons 2–7).

1

What gets tested

Three kinds of check, from smallest to biggest: the sums (totals, streaks, "is this late?"), the server (does it refuse bad input, does it keep people's data apart), and the whole app, clicked through like a person would.

2

Tests for the sums

Say to your agent
Add tests for the calculations, including awkward cases: no entries yet, exactly midnight, two entries at the same time.
$ npm test

Your agent runs these after every change. You can too.

Keep the logic in one module the Worker and the browser both import, so the tests cover what both run.

3

A click-through, like a person

Your agent opens a real browser at phone size and uses the app: signs up, adds things, edits, undoes, deletes, opens Settings, signs out. Any error stops it.

Say to your agent
Write a full click-through test of the app in a real browser at phone size, and run it before every release.
A test fails because I asked for a change
That's expected: the test was written for the old way. Your agent should update the test in the same change, and say so.
4

Two people, and no signal

Shared apps break in shared ways. The click-through also signs in as a second person to check they see each other's entries, and switches the signal off to check nothing is lost.

5

Screenshots you actually look at

After every change, your agent takes pictures at phone and computer size and opens them for you. Look: tests can't tell you something looks wrong.

  • Unit tests pass
  • Sign in and out
  • Two phones see each other's entries
  • Works offline, then syncs
  • Screenshots look right
  • You said "yes, put it live"
You should see

A list of what was checked, each ticked off, then pictures of what changed.

6

Honest results, then your yes

If something failed or was skipped, your agent should say so plainly, not bury it. Then, and only then, it asks: "Shall I put it live?"

House rule: a yes covers one release. The next one gets its own question.

Did it work?

Tick these off. They're saved in this browser, so you can come back later.

  • My app has tests, and they pass
  • A full click-through runs in a real browser
  • I looked at the screenshots before saying yes
  • Nothing went live without me saying so