mirror of
https://github.com/tester-army/e2e.git
synced 2026-11-24 01:50:04 +08:00
215 lines
9.1 KiB
Plaintext
215 lines
9.1 KiB
Plaintext
---
|
||
title: Debugging a run
|
||
description: Read the report, open the evidence, watch the browser, and see what the model was sent.
|
||
---
|
||
|
||
Start with the failure in the terminal. Every run also writes
|
||
`.e2e/report.json`, with links to the screenshots, traces, downloads, and
|
||
recordings captured by the selected engine.
|
||
|
||
## Read the failure
|
||
|
||
The `list` reporter's `Failed Tests` section shows the error, failing line,
|
||
and screen at failure. For a failed locator, it also lists nearby matches
|
||
that may explain the problem. The exit code identifies the failure type:
|
||
|
||
| Exit | Meaning | Retry the job? |
|
||
| ---: | --- | --- |
|
||
| 1 | A test failed | Only if the test is flaky |
|
||
| 2 | Configuration, collection, or policy | Fix the reported problem first |
|
||
| 3 | Engine, app process, model provider, or artifact failure | If the cause is temporary |
|
||
| 4 | An internal runner error | Report it |
|
||
| 130 | The run was interrupted | |
|
||
|
||
## The failure pages
|
||
|
||
Use `--reporter list,markdown` to write `.e2e/summary.md` and a page for each
|
||
failed or flaky test under `.e2e/failures/`. A failure page includes the
|
||
source line, steps, recent model turns, and screen text:
|
||
|
||
````markdown
|
||
# ✗ todos › archives a todo
|
||
|
||
`tests/todos.e2e.ts` · failed · 16.2s
|
||
|
||
**ASSERTION_FAILED**
|
||
|
||
```text
|
||
agent.act failed: the todo exposes only a "Delete" button; no "Archive" button is present.
|
||
```
|
||
|
||
Look at: `tests/todos.e2e.ts:8`
|
||
Failed the same way on both attempts: **ASSERTION_FAILED** at step 2.
|
||
|
||
## Steps
|
||
1. ✓ `app.open` "/todos" (35ms) — `tests/todos.e2e.ts:4`
|
||
2. ✗ `agent.act` "Archive the todo" (16.1s, 6 model calls) — **ASSERTION_FAILED** — `tests/todos.e2e.ts:8`
|
||
|
||
## Agent turns of step 2
|
||
**Turn 2** `tap({"target":"n19"})`
|
||
> Tapped #n19.
|
||
> Screen changes since revision b4 (now revision b6, path /todos, 29 nodes): 4 added, 2 changed.
|
||
> added #n29 button "Delete Groceries"
|
||
|
||
## Screen at failure
|
||
URL: `http://127.0.0.1:3000/todos`
|
||
```text
|
||
#n18 textbox "New todo"
|
||
#n19 button "Add"
|
||
#n34 listitem "Groceries" testid="todo"
|
||
#n37 button "Delete Groceries"
|
||
```
|
||
````
|
||
|
||
`Look at` points to the failing call. Assertion failures include expected
|
||
and observed values; locator failures include the requested locator and
|
||
nearby matches. Repeated failure details help you compare attempts.
|
||
|
||
## The report
|
||
|
||
Use `.e2e/report.json` for scripts and integrations. `--reporter json` prints
|
||
the same document to stdout:
|
||
|
||
```bash
|
||
jq '.run | {status, exitCode, errors}' .e2e/report.json
|
||
jq '.run.results[] | select(.status != "passed") | {titlePath, file, status}' .e2e/report.json
|
||
jq '.run.results[] | select(.status != "passed") | .attempts[-1]
|
||
| {status, error, failure, steps: [.steps[] | select(.status != "passed") | {api, label, source, status, error}], artifacts}' .e2e/report.json
|
||
```
|
||
|
||
Check `run.errors` for run-level failures, then the last attempt of each
|
||
failed result:
|
||
|
||
- `error` contains the code, message, source line, and assertion details.
|
||
- `failure` identifies the screen and screenshot artifacts and any locator
|
||
candidates.
|
||
- `steps` shows the calls leading to the failure. Failed agent steps include
|
||
recent model turns.
|
||
- `artifacts` lists the captured files.
|
||
|
||
## Artifacts
|
||
|
||
Artifacts land under `.e2e/artifacts/`, one directory per attempt:
|
||
|
||
- **Screenshots.** Failed attempts capture one when screenshots are enabled
|
||
and pixels are allowed. The built-in `agent.assert` also captures one after
|
||
either verdict unless `screenshot: false` disables it. Capture can fail or
|
||
be withheld. Use `app.screenshot('label')` to capture one explicitly.
|
||
- **Playwright traces** when the `trace` artifact kind is enabled and capture
|
||
succeeds. Open a trace with `npx playwright show-trace <file>`.
|
||
- **Downloads** saved through `web.waitForDownload`, recorded with kind
|
||
`download`.
|
||
- **Videos** and **agent transcripts** when you ask for them; see below.
|
||
|
||
After a secret fill, the runner withholds screenshots from agent calls and
|
||
`app.screenshot()` for the rest of the attempt.
|
||
|
||
Playwright traces and videos need separate care. Trace redaction replaces
|
||
secret text with `<secret:name>`, but it cannot remove a secret rendered as
|
||
pixels. A trace marked `redaction: "complete"` can still contain those
|
||
images. Videos mask nothing and are marked `redaction: "incomplete"`.
|
||
|
||
If trace rewriting fails, the runner deletes the trace from the attempt's
|
||
artifact directory. For a path outside that directory, it withholds the
|
||
artifact with `TRACE_WITHHELD` and leaves the file untouched. See the
|
||
[security model](/security#where-redaction-stops) for all redaction limits.
|
||
|
||
## Watch it happen
|
||
|
||
```bash
|
||
npx e2e run --headed # a visible browser
|
||
npx e2e run --video # requires an engine that records video
|
||
```
|
||
|
||
`--video` requires recording support from every selected engine. Unsupported
|
||
engines fail configuration with `UNSUPPORTED_ARTIFACT`. Playwright records
|
||
WebM files; agent-device records MP4. Restarts can produce multiple files.
|
||
|
||
To keep recordings only for failed attempts, configure:
|
||
|
||
```ts
|
||
artifacts: { kinds: ['video'], video: { retain: 'on-failure' } },
|
||
```
|
||
|
||
## Console output
|
||
|
||
`console.log` and `console.error` inside a test print as the test runs, above
|
||
the live view, under a heading that names the stream, the target, the file,
|
||
and the test:
|
||
|
||
```text
|
||
stdout | web tests/todos.e2e.ts > adds a todo
|
||
hello from the test
|
||
```
|
||
|
||
Nothing is buffered or dropped: every line appears when it is written, in a
|
||
pipe or a CI log as much as in a terminal. The output is not part of the
|
||
report; use `expect` or an artifact for anything a later reader needs.
|
||
|
||
## Agent steps
|
||
|
||
Use these flags to inspect agent behavior:
|
||
|
||
```bash
|
||
npx e2e run --debug # timings and a step table on stderr
|
||
npx e2e run --ai-trace # every model call, for a trace viewer
|
||
npx e2e run --no-cache # run the agent live instead of replaying
|
||
```
|
||
|
||
`--debug` appends two tables after the reporter's output: phase timings for
|
||
the run, and one row per agent step with its duration, model calls, tokens,
|
||
prompt-cache share, and cost when the provider reports one. Each planned
|
||
step also saves its model transcript as an artifact.
|
||
|
||
```console
|
||
[e2e debug] agent steps (execution order, model anthropic/claude-sonnet-4.5, total $0.0312)
|
||
step total model observe action calls tokens in/out cached cost
|
||
act "add a todo named groceries" 3.9s 2.8s 410ms 620ms 3 9412/388 61% (5740) $0.0198
|
||
assert "the list shows groceries" 1.2s 1.1s 88ms 0ms 1 3120/41 0% (0) $0.0114
|
||
```
|
||
|
||
`--ai-trace` writes model requests and responses to `.e2e/ai-trace.json`.
|
||
Read it with [unbox-ai](https://github.com/tester-army/unbox-ai) to inspect
|
||
prompts, tool calls, and token usage:
|
||
|
||
```bash
|
||
npx unbox-ai runs .e2e/ai-trace.json
|
||
npx unbox-ai summary .e2e/ai-trace.json --run 1
|
||
```
|
||
|
||
Each agent step appears as a run in the AI trace, with one entry per model
|
||
call. It contains the redacted input sent to the model; image bytes are
|
||
replaced with byte counts. Use unbox-ai to inspect it instead of reading the
|
||
large raw JSON file.
|
||
|
||
Replayed steps make no model call and leave no AI trace. Add `--no-cache`
|
||
when you need to inspect the whole flow or rule out a stale recording. See
|
||
[Caching agent steps](/cache).
|
||
|
||
## Common errors
|
||
|
||
| Code | Usual cause | Fix |
|
||
| --- | --- | --- |
|
||
| `APP_UNREACHABLE` | Nothing answers at `url`, or `command` never became ready | Set `command.log` and read it; check the port; raise `startupTimeout` |
|
||
| `APP_ALREADY_RUNNING` | Something already serves `url` when the runner wanted to start `command` | Stop it, or set `reuseExisting: true` for local runs |
|
||
| `LOCATOR_NOT_FOUND` | Wrong role or name, text not exact, element inside an iframe, page not open | Read the markup for the accessible name; try `exact: false`; `web.frameLocator` for iframes; `--headed` to look |
|
||
| `LOCATOR_AMBIGUOUS` | Two matches: a hidden duplicate, a repeated label | Add `{ name }`, scope under a container, `filter`, `first()`, or `{ visible: true }` |
|
||
| `ASSERTION_FAILED` | The expectation is wrong, or the state settles after 5 s; for `agent.assert`, the judgment was false | Compare with the screenshot; `{ timeout }` on the matcher; rewrite the question |
|
||
| `ASSERTION_INCONCLUSIVE` | `agent.assert` asked about something the screen does not show: the value is on another page, still loading, or only in pixels | Open or wait for the right screen first; ask about what is visible; add `vision: true` when the answer is in pixels |
|
||
| `ACTION_FAILED` | Element covered, disabled, or detached, or an operation timed out | Wait on the right condition with `expect` first; close overlays |
|
||
| `STEP_BUDGET_EXHAUSTED`, `STEP_TIMEOUT` | The agent ran out of model calls or time | Scope the goal to one step; raise `timeout` for slow providers |
|
||
| `MODEL_UNAVAILABLE` | No model constructed in the config | See [Choosing a model](/models) |
|
||
| `MODEL_PROVIDER_FAILED` | Bad key, rate limit, no credits | Check the key the provider reads and the quota |
|
||
|
||
Every code, its class, and its exit code are in the
|
||
[errors reference](/reference/errors).
|
||
|
||
<CardGroup cols={2}>
|
||
<Card title="CLI reference" icon="terminal" href="/reference/cli#e2e-run">
|
||
Every flag of `e2e run`.
|
||
</Card>
|
||
<Card title="Errors" icon="triangle-exclamation" href="/reference/errors">
|
||
Every error code.
|
||
</Card>
|
||
</CardGroup>
|