Record video
Doc Detective can record a test as a video and pick the right capture engine for you. This guide is the entry point to the Recording section and covers recording a flow, stopping it, and choosing an engine. The section’s other guides cover the related capabilities: Detect visual regressions with checkpoints, Record video automatically, and Narrate a recording with annotations. The record and stopRecord action references and the generated record and stopRecord schemas are where you look up every field.
Before you begin
Make sure you have the following:
- Doc Detective installed.
- Chrome, for headless recording. Doc Detective records headless Chrome with no display. Other browsers need a visible display; caveats come later in this guide.
- A directory where you can create a
.spec.jsonfile.
The steps in this guide work the same in every authoring style. Write them in a standalone .spec.json, inline in a doc source file, or let Doc Detective detect them from prose.
Recordings are video only, with no audio track.
Record and stop
The record action starts a recording, and a later stopRecord step ends it. Like screenshot, record takes a boolean (record: true), a string path (record: "flow.webm"), or an object for more control. Supported formats are .mp4, .webm, and .gif, in any letter case, such as Demo.MP4.
record: true saves <stepId>.mp4 in outputDir. outputDir defaults to your config file’s folder, or to the current folder when you run without a config file. The GitHub Action sets outputDir to the runner’s temporary directory instead. Set the step’s stepId to choose the filename. Without one, Doc Detective derives an ID from the test and the step, which stays the same until you change the step. A relative path, such as record: "flow.webm", resolves against the spec file, or against the current folder when relativePathBase is cwd.
Every recording ends at a stopRecord step; Doc Detective finalizes any recordings still open at the end of the run. stopRecord targets a recording in one of two ways:
- Untargeted (
trueornull): stops the most recently started recording that’s still active (last in, first out). This is the common case, when only one recording runs at a time. - By name (a string, or
{ "name": "<name>" }): stops the active recording with thatname, wherever it falls in the active set.
A single context can run more than one recording at once, such as a full session alongside a shorter clip. Give each record step a name so a later stopRecord targets the right one. For that pattern, see Multiple overlapping recordings.
By default (overwrite: "false"), a record step whose file already exists is skipped and reports SKIPPED. For the overwrite modes that re-record on change, see Detect visual regressions with checkpoints.
For the full set of fields, see the record and stopRecord action references and the record and stopRecord schemas.
Choose a recording engine
Recording uses one of two engines. If you don’t set engine, Doc Detective uses the browser engine for any Chrome context, headed or headless, and ffmpeg otherwise. A context that names no browser runs headless Chrome, so it records with the browser engine.
browserrecords the Chrome viewport for the current tab only, and keeps recording across navigations. It works headless, with no display. It’s always safe to run concurrently, because each context records its own tab.ffmpegrecords the whole screen, so it works for any application, not just Chrome. It needs a headed context. Doc Detective installs FFmpeg automatically.
Set engine as a string to pick an engine with its defaults, or as an object to tune it:
Engine choice affects concurrency. The browser engine always runs in parallel. The ffmpeg engine captures the shared display, so Doc Detective serializes an ffmpeg recording with every other browser-driven test. They take turns on the display, and you don’t need to set concurrentRunners to 1. Jobs that don’t drive a browser, such as httpRequest and runShell steps, keep running in parallel. On a Linux host with no display, the ffmpeg engine needs Xvfb, which gives a headed context a virtual display to capture.
Recording a native app surface or a mobile device screen follows different rules. See Recording app surfaces and Recording on mobile devices. For engine details, see Recording engines and Docker and headless.
Verify it works
- A recording that saved reports
PASS. - A headless context that the engine can’t record, such as headless Firefox, skips the
recordstep and reportsSKIPPED. See Recording is skipped in CI.
Videos land in the run’s output directory and the per-run artifact tree. To see where they land and how to consume them in CI, see Reporters and artifacts.
Troubleshooting
Recording is skipped in CI
Cause: the context is headless Firefox or Safari, or it uses the ffmpeg engine headless. Neither draws anything on a display to capture.
Solution: record in Chrome, which records headless with the browser engine. Otherwise run headed, and on a Linux host with no display install Xvfb (see Docker and headless). Even when the capture is skipped, a span with checkpoints still reports staleness against its committed baselines (see Detect visual regressions with checkpoints).
Two concurrent recordings overlap on Windows or macOS
Cause: the recordings share one physical display, so their captures overlap.
Solution: use the browser engine, which records each context’s own window, or let Doc Detective serialize the ffmpeg recordings on the shared display.
What’s next
- Detect visual regressions with checkpoints to watch a recording for visual drift.
- Record video automatically for every driver-based context.
- Narrate a recording with annotations that stay up across the flow.
- Follow the worked recording example end to end.
- Capture screenshots for stills, comparisons, and annotations.
- Run in CI and at scale.