Console and network
Inspect browser logs and requests, and choose which errors should fail a test.
When a task never appears after Save, a failed request or browser error may explain why. Use the captured console and network records to investigate the run, or make selected errors fail otherwise passing tests.
Inspect a test Link to Inspect a test
Run your test, then use the run folder printed in the terminal to inspect it. The test identifier combines its file and title, as shown in the run result.
npx retest run tests/tasks.retest.tsnpx retest inspect .retest/runs/<time> --test 'tests/tasks.retest.ts > saves a task'Below the steps, inspect shows each page's capture status and counts, its first 50 console entries and its first 100 requests. Add --json to read all retained records. The files under diagnostics/ also hold the full retained capture.
Console records include messages, uncaught errors and unhandled promise rejections on supported engines. Network records include each request's method and address, its response status, and its duration or failure when the browser provides them. A 503 response and a refused connection are different records: the connection failure has no response status.
Decide which errors fail a test Link to Decide which errors fail a test
Diagnostics do not fail tests by default because an error may be the state you intended to test. Enable a strict policy when your suite should reject particular kinds of errors.
import { chrome, defineConfig } from '@rehearsal-labs/retest'export default defineConfig({ apps: { web: chrome({ baseUrl: 'http://127.0.0.1:4173' }) }, diagnostics: { strict: { runtimeErrors: true, httpErrors: true, allow: ['/favicon.ico'], }, },})This fails an otherwise passing test for an uncaught error, an unhandled rejection or a response with status 400 or higher. Rejections handled later do not count. The allow list excludes a record when its message or address contains an entry, so /favicon.ico is a substring match.
You can also enable consoleErrors for errors logged by page code, or transportFailures for failed connections. Transport rules exclude cancelled requests and failures accompanying a response with status 400 or higher. A strict match reports host_check_failed, names the matching records and makes the run exit 1.
Check capture status Link to Check capture status
Console and network capture each have a state. Read that state before treating an empty log as evidence that nothing went wrong.
| State | Meaning |
|---|---|
complete | Everything within the stated scope was captured. Zero records means none were produced. |
partial | Some records were lost or unreadable. The capture gives its reason. |
unavailable | Capture could not start or its file could not be saved. |
disabled | The run turned capture off. |
A strict rule cannot pass when the capture it needs is incomplete. With no matching error, that produces reporting_failed and exit 2. Setting diagnostics: { requireComplete: true } requires both captures to be complete even without a strict rule. An existing test failure stays first.
The default bounds keep up to 1,000 console messages and runtime errors in 1 MiB, and 1,000 request hops in 2 MiB, across an attempt's apps. Dropped records make capture partial. See Configuration options for the limits, or use diagnostics: { capture: false } to disable capture.
Understand the scope Link to Understand the scope
| Engine | Console | Network |
|---|---|---|
| Chromium family | Document, frames in its process and dedicated worker messages | Document and frames in its process |
| WebKit | Document and frames, including other sites | Document and frames, including other sites |
| Firefox | Unavailable | Document and frames, including other sites |
Firefox has no console capture. A strict console rule, a strict runtime error rule or requireComplete therefore prevents its tests from passing. Network rules still work.
Capture does not cover service workers' own activity or shared workers. WebKit leaves out dedicated worker messages and requests; Firefox records dedicated worker requests as the page's. Popup diagnostics are unavailable.
Electron captures its first window only. Diagnostics are partial when that window already shows a page other than about:blank, or Retest cannot tell. An app that loads its page at launch therefore has partial capture, so requireComplete prevents its tests from passing.
Native apps have different sources: owned standard output and an explicitly configured network metadata file. They do not provide browser console or JavaScript error classifications. See iOS simulator apps and macOS apps for their setup.
Know what is kept Link to Know what is kept
The records contain no request or response bodies or headers. Addresses omit queries, fragments and credentials; token-like path segments and known secret values are hidden before records are saved.
A request answered by a route is marked as mocked. Diagnostics reach an AI judge only when a check explicitly selects them as evidence.