Lesson 2 of 5 in Close the loop · 12m

Verify in the browser

After this lesson you have the agent check its own front-end work the way a user would see it: it opens the page, reads the console and network log, asserts on what's on screen, and keeps a screenshot baseline that catches the change nobody meant to make.

Compiling is not working

For back-end code, a passing test suite is strong evidence. For anything a person looks at, it's weak. A component can type-check, render without throwing, pass its unit tests, and still show a blank card because an API call returned 401. The agent won't know unless it looks.

So make looking part of the job. A front-end task isn't done until the agent has loaded the page in a browser and checked three things:

  • The console is clean. No new errors, no unhandled promise rejections. Warnings that were there before the change are fine. New ones need a reason.

  • The network is clean. No 4xx or 5xx responses, no failed requests, for the flow you changed.

  • The page shows what it should. The text, the element, the state you asked for, checked by an assertion rather than described from memory.

Then it shows you a screenshot. The screenshot is for you. The assertions are for the agent.

Assertions over eyeballing

A model looking at a screenshot will usually tell you it looks fine. That's the same problem as the agent grading its own work, with pixels. A check that passes or fails on its own is better:

  • "The heading reads Pricing."

  • "There are exactly three plan cards."

  • "After clicking Subscribe, the URL ends in /checkout."

  • "The Save button is disabled until the email field is filled."

Each of these is one call and returns a plain pass or fail with the actual value when it fails. Put them in the brief as done-when lines, the same way the previous lesson put a failing test there.

Baselines catch what you didn't ask about

Assertions check what you thought of. A visual baseline checks everything else. Save a screenshot of a page in a known-good state, then compare against it after each change. A shifted margin, a missing icon or a font that stopped loading shows up as a pixel difference, even though no assertion mentioned it.

Use baselines on a few pages that matter and change rarely. On a page under active redesign, every compare fails and the baseline becomes noise.

A worked example

You asked the agent to add a "Copy link" button to each row of a share dialog. Your brief ends:

Done when, at http://localhost:3000/share:
- each row has a button with the text "Copy link"
- clicking the first one shows the text "Copied"
- the browser console has no errors and no request failed
Show me a screenshot of the dialog when you're finished.

The agent makes the change, then opens the page in the built-in browser, counts the buttons, clicks the first, and waits for "Copied". That check fails: the clipboard call threw. It reads the console, finds NotAllowedError from the clipboard API, fixes the handler, and runs the checks again. Now they pass, the console is clean, and the screenshot shows the dialog. The bug was caught and fixed without you opening the page.

Go further
  • The built-in browser — tabs, engines, design mode and DevTools
  • Browser — every browser_* tool, sessions, mocks and recordings
  • Workflows and tab monitors — replay a recorded browser action from Flows
  • Tests are the contract — the done-when line, for code without a page

Keep going with Close the loop

This is one of 5 lessons in the course. Enroll to get the rest of the course, with an AI tutor that knows the material, flashcards and a certificate when you finish.

Enroll for free

More free lessons from this course