Run folder and events

Find saved run files and read their event types, identities and schemas.

A run folder holds the result, events, logs and evidence from one run. Use it to investigate later or feed results into your own tools without opening a browser again.

Terminal
npx retest inspect .retest/runs/<time>npx retest report .retest/runs/<time>

The first command prints the saved result; the second writes report.html. Both also work with incomplete runs when enough events remain to reconstruct a result. Debugging a failure walks through a test's timeline.

Files and folders Link to Files and folders

The default folder is .retest/runs/<time>. Pass --output <dir> to choose another new or empty folder. Retest refuses to overwrite a folder that already holds files.

Path inside the runContents
events.jsonlOne version 1 event per line, written as the run proceeds.
result.jsonRunResult written at the end through an atomic rename.
logs/*.logTest-file stdout and stderr, browser output and output of servers Retest started.
artifacts/*-failure.pngFailure screenshots, named with a test slug, attempt id and app when applicable.
diagnostics/*.jsonlOne session's console, runtime-error and network records.
artifacts/<attempt>/<app>/Recordings, frames, AI evidence, screenshot comparison images and downloads.
electron/<app-and-target>/<launch>/windows.jsonWindow inventory for each Electron launch. The app and target form a slug.
report.htmlPortable report, when requested with report or --reporter html.
states/Saved sign-in states while the run is active; removed during cleanup.
uploads/<attempt>/Temporary files created for content-based uploads while the test runs.

Log names include a slug and hash. A browser-only run uses logs/browser.log; configured targets use logs/browser-*.log, with extra instance suffixes for browser pools. App-server logs use logs/app-*.log. Read paths from records instead of reconstructing filenames.

The last-run selection record is outside this folder, at .retest/last-run.json. It feeds --last-failed. A programmatic host can change its path or disable it with lastRunFile: false.

Artefact paths and retention Link to Artefact paths and retention

Session artefact folders use an attempt id and a shortened app name with a hash. The following patterns describe files in those folders. Formats depend on what captured or encoded the media.

PatternContents
screenshot-evaluation-<n>.pngScreenshot captured for an AI check; the extension may also be jpg.
thumbnail-*.pngThumbnail of a screenshot or recording; the extension may also be jpg.
recording-<n>.mp4Playable video, or webm when that container was selected.
recording-<n>.mp4.partialVideo still being written, or an unfinished output.
frames-<n>/<index>.jpgNumbered frames retained for an AI check; frames may also be png.
<name>-<observation>-expected.pngReadable baseline image kept after a failed screenshot comparison.
<name>-<observation>-actual.pngActual screenshot kept after a failed comparison, including when no baseline exists.
<name>-<observation>-diff.pngDifference image kept when the failed comparison had a readable baseline.
downloads/<filename>Saved download, using a safe form of the browser's suggested name.

Failure screenshots and diagnostics use slug-based paths, while other media uses the session folders above. Follow each path stored in an event or result instead of assuming a single layout.

Artefact references are relative to the run folder and use forward slashes, so you can move the folder. Retest's artefact reader refuses invalid references, symbolic links, hard links, special files and files beyond its size limit. Screenshots are pixels and are not text-redacted.

Logs, screenshots, frames, downloads, diagnostics and reports remain. With recording.keep: 'failures', recordings of passed attempts and their recording thumbnails are removed, except recordings used by AI checks. Unreferenced partial recording files may be removed after the media process closes. Removal events record each request and its result.

Saved states contain session cookies and are deleted at cleanup. SIGKILL can leave them behind because cleanup cannot run. Recordings and evidence describes capture policy and retention in more detail.

Event envelope and identity Link to Event envelope and identity

Every event has the following envelope. Event-specific fields then describe what happened. Sequences increase within one run; elapsedMs uses the run's monotonic clock rather than wall-clock differences.

FieldMeaning
schemaVersion1.
runIdRun identity.
sequenceEvent order within the run.
timeWall-clock timestamp.
elapsedMsMilliseconds since the run began, on its monotonic clock.
originparent for Retest's own records, child for a test-process report.
typeOne of the event types below.
Scope fieldMeaning when present
testIdRelative file path, group names and test title joined with >.
attemptIdIdentity of this execution attempt.
variant, variantKeyApp-to-target map and its printable key.
sessionApp name on events, or page for a browser-only run.
sessionIdOne app page in one attempt, such as k3v9q0x2mb:web.
stepIdNamed step or hook containing the operation.
observationIdLook that supplied the evidence, when the event rests on a look.

Auxiliary records use app where events use session. Observation ids start again within each attempt, so join records with the attempt and session identities too. Page and layout looks can have ids without their own observation event, so missing numbers do not imply missing records.

Run and collection events Link to Run and collection events

TypeRecord
run.startedRetest and Node versions, platform, root, files and effective run options.
collection.completedOne file's collected tests, locations, options and variants.
collection.failedA file that could not be collected, with its failure.
file.failedA collected file whose process failed outside a test.
run.narrowedFocused declarations and how many tests they kept.
app.startedApp server started, including readiness address, pid and startup duration.
app.reusedAn already-running app server was reused.
app.failedApp-server startup failed.
browser.startedBrowser product, version, available build, engine, target and process identity. Further pool or Electron launches may add instances.
native.startedNative session identity, app, target and execution facts.
native.endedNative session ended, with any unresolved lifecycle or input outcomes.
run.finishedRun status, exit code, completeness, counts, duration and optional failure or evidence state.
run.outcomeCorrected final outcome after reporter shutdown, when that changes the result.

Attempt and resource events Link to Attempt and resource events

TypeRecord
lock.acquiredNamed locks held by the attempt, wait duration and blockers.
resource.acquiredDesktop, devices or data folders held by the attempt.
session.reservedHost-managed browser session capacity acquired for the owner.
lease.takenComplete resource lease and release budget.
lease.expiredResources not released within the cleanup budget.
session.releasedReserved sessions returned, with the release reason.
test.startedTest source, name and execution identity, including bundle, configuration and starting state.
preparation.finishedA host preparation's outcome and reported facts.
cleanup.finishedA host cleanup's outcome.
state.savedSaved state name, app, target and session, without its contents.
state.restoredRestored state name, app, target and session.
test.finishedStatus, assertion count, duration, failure, cleanup failures and ending; may include the final bundle and checks not run.

A skipped test has test.finished without test.started. Waiting for locks and resources happens before the test starts and does not consume its test budget. For programmatic runs, see Use Retest from code.

Steps, actions and checks Link to Steps, actions and checks

TypeRecord
step.startedNamed step, parent step, source location and optional hook kind.
step.finishedStep status, duration and optional failure.
action.completedCommand, locator, page and duration, plus relevant input metadata.
action.failedThe same action facts with its failure.
navigationAddress, title, cause and document change.
observationRedacted locator look served to the test process before it received the answer.
assertion.passedMatcher, comparison and available observation identity, with judgedBy.
assertion.failedAssertion facts and failure. Soft failures carry soft: true.
host_check.passedParent-run page check and the actual page it read.
host_check.failedHost check facts and failure.
evaluation.finishedAI check verdict, criteria, evidence references, judge identity and available usage.
baseline.writtenScreenshot baseline path, dimensions and observation, including whether it replaced a file.
inbox.readInbox name, read counts, wait and redacted message metadata.
dialogDialog type, redacted text, answer and who answered it.
popup.openedOpener and popup identities, address and available title.
popup.closedPopup session closed.
downloadSuggested filename, redacted address, completion state and available saved path.
routeRoute addition, removal or answer, including a safe response summary.

navigation.cause is goto for explicit navigation methods, action for navigation attributed to dispatched input, or page otherwise. document is new or same. Navigation and action addresses omit queries and fragments; page assertions can retain the whole redacted address they compared.

Only step and assertion events originate in the test process. The parent rejudges passed locator and page assertions on its recorded look and marks them judgedBy: 'parent'. Value checks are judgedBy: 'child' because those values exist in the test process.

Evidence and media events Link to Evidence and media events

TypeRecord
evidence.capturedFailure screenshot path, session, source and capture time.
evidence.failedWhy a failure screenshot was unavailable or withheld.
diagnostics.startedCapture scope, limits and any strict or required policy.
diagnostics.finishedSession capture summaries and artefact reference.
recording.startedRecording identity, source, capture mode, output, dimensions, rate and clock start.
recording.finishedRecording state, video facts, frame counts, gaps and clock mapping.
media.startedMedia process identity and encoder readiness.
media.failedMedia or encoder startup failure.
media.lostMedia process exit, affected recordings and whether it will restart.
media.closedConfirmed media-process shutdown and cleanup problems.
media.leftoversInspection and cleanup of a previous killed run's recorded outputs.
capture.withheldPixel withholding began around secret entry.
capture.resumedPixel withholding ended, with its reason and time span.
capture.native_entryNative field classification and pixel-policy decision, without the secret value.
capture.masked_entryCapture continued because secret entry was verified as masked.
artifact.removal_requestedPersisted request to remove a retained artefact.
artifact.removedRequested file removal succeeded.
artifact.removal_failedRequested file removal failed or was refused; the file remains.

Diagnostics artefact lines Link to Diagnostics artefact lines

Diagnostics artefacts are separate JSON lines files. Their line types are not RetestEvent types. They begin with capture.started, end with capture.finished and contain the record types below. Their identities name the test, attempt, app and session.

TypeContents
consoleLevel, source, cleaned message and available source location.
runtime_errorUncaught error or unhandled rejection and bounded stack.
network.requestRequest id, method, cleaned address and redirect relationship.
network.responseStatus, content type and available cache or mocked-response facts.
network.finishedRequest completion and available transfer size.
network.failedTransport failure or cancellation.
network.pendingRequest still pending when capture ended, with its reason.

Capture records include their scope and completeness. Retest records no network headers or bodies. See Console and network for engine coverage and Results and exit codes for capture states.

Read and validate a folder Link to Read and validate a folder

readRunFolder validates saved results and events and returns { source, result, events, warnings }. It reconstructs a missing result from events and marks it incomplete. Invalid folders throw RunFolderReadError.

TypeScript
import { readRunFolder } from '@rehearsal-labs/retest/runner'const folder = readRunFolder('.retest/runs/saved-run')const failedActions = folder.events.filter(event => event.type === 'action.failed')console.log(folder.result.exitCode, failedActions.length)console.log(folder.warnings)

Replace the example path with your saved folder. If the last event line was cut off during writing, the reader leaves it out and adds a warning. Invalid earlier lines, mixed run ids or non-increasing sequences make the event log unreadable. With a valid result.json, a damaged event log becomes a warning and the result remains readable.

The protocol export supplies retestEventSchema, runResultSchema, eventSchemaUrl and resultSchemaUrl. Installed JSON Schemas are dist/schemas/event-v1.schema.json and dist/schemas/result-v1.schema.json. Use a reader at least as new as the Retest version that wrote the folder. Version 1 rejects unknown fields, so an older reader may refuse newer records.

A host running code it does not control should take authoritative results from runFiles and events from its reporter. The test process can write to the run folder, so those files are saved copies rather than a trust boundary. Use Retest from code describes host isolation and required checks.

Next steps Link to Next steps