Browser tests

Declarative tests that agents save and a local Playwright runner executes, with screenshots, logs and traces.

Agents prove their work with browser tests. A test is a list of declarative steps; the runner executes it in headless Chromium and keeps the evidence.

Tests

A test has a name, an absolute http(s) target URL, 1 to 100 steps and an expected outcome. Steps:

Step Does
goto open a URL
click click an element
fill type into a field
press press a key
wait_for wait for an element
expect_text fail unless the text appears
expect_url fail unless the URL matches
screenshot save a named screenshot

Agents save tests and queue runs with petal_tests. A test can join the project’s suite (in_suite) only for outcomes you stated; rerun runs the whole suite.

Runs and evidence

A run is one execution: queued, running, passed, failed, cancelled or error, with a result per step. It can belong to a delivery and name a revision.

Evidence per run: screenshots (PNG), logs (text) and, on failure, a Playwright trace (zip). Each file is at most 10 MiB and a run keeps at most 50. Evidence expires after evidence_retention_days (default 30). It shows on the run page in the dashboard.

The local runner

petal serve starts node runner/dist/index.js and restarts it when it exits.

  • --runner-dir <DIR> runs node <DIR>/dist/index.js (default runner, relative to the working directory).
  • --no-runner starts no runner; runs stay queued until one claims them.

Without node or a built runner, petal serve warns and keeps serving. The first SIGINT or SIGTERM lets the current run finish; a second exits at once.

Runner settings

In config.toml:

  • runner_token: the token the runner sends on /api/v1/runner/*, the only routes it can call. Created on first start.
  • evidence_retention_days: days evidence is kept before the hourly purge.

Environment (set by petal serve; set them yourself to run a runner by hand):

Variable Meaning
PETAL_URL Frond base URL (default http://127.0.0.1:7777)
PETAL_RUNNER_TOKEN runner_token from config.toml (required)
PETAL_RUNNER_ID runner id (default runner-<hostname>-<pid>)
PETAL_BROWSER Chromium executable (default: Playwright’s)
PETAL_ALLOWED_HOSTS comma list of target hosts (example.com exact, *.example.com subdomains only); other requests, redirects and WebSockets are blocked
PETAL_RUNNER_STDIN_LIFELINE 1: exit when stdin closes (set by petal serve)

PETAL_ALLOWED_HOSTS is required whenever PETAL_URL is not a loopback address; the runner refuses to start without it. With a loopback URL and no list, there is no restriction.