stopRecord
The stopRecord action stops a video recording started by an earlier record action and saves the video file.
You can choose which recording to stop:
- Most recent (boolean or null):
stopRecord: trueorstopRecord: nullstops the most recently started recording that’s still active (last in, first out). Use this when only one recording is active, which is the common case. - By name (string):
stopRecord: "<name>"stops the active recording with a matchingname. Use this to stop a specific recording when several overlap. - By name (object):
stopRecord: { "name": "<name>" }is the object form of targeting a recording byname.
When you target by name, Doc Detective stops that recording wherever it falls in the active set, not just the most recent one. For more about running several recordings at once, see Multiple overlapping recordings.
The same untargeted and named forms stop recordings of every kind. Browser, desktop app window, and mobile device-screen recordings all live on the same stack. For device recordings, stopRecord is also the point where the video transfers from the device and saves. It converts to .webm or .gif when the target path calls for it.
Note: To finalize and save a recording started with the
recordaction, include astopRecordstep. Doc Detective also records each context on its own by default (autoRecord). An untargetedstopRecordskips that automatic recording, which Doc Detective finalizes at the end of the context. If therecordstep was SKIPPED because the host can’t record, itsstopRecordis SKIPPED too.For comprehensive options, see the
stopRecordreference.
Outputs: when a recording saves, the action exposes the following values in its outputs object. To capture any of them for later steps, use the step-level variables object with the matching expression. Metadata fields are best-effort. When Doc Detective can’t read the saved file’s metadata, it omits those fields without failing the step:
$$recordingPath: the absolute path of the saved video file.$$format: the saved file’s format (mp4,webm, orgif).$$duration: the video’s duration in seconds.$$widthand$$height: the video’s dimensions in pixels, after any window or viewport crop.$$fps: the video’s frame rate.
When the recording ran with checkpoints enabled, the outputs also include:
$$checkpoints: per-checkpoint results (file name, variation, whether the baseline was missing).$$maxCheckpointVariation: the highest variation across the span’s checkpoints. Beyond the configuredmaxVariation, the step returns WARNING.$$seededBaselines: how many baselines this stop seeded (first run only;0when every checkpoint compared against an existing baseline).$$checkpointErrors: how many checkpoints couldn’t be captured or compared, such as an aspect-ratio mismatch against the baseline. Any errors also return WARNING, because an incomparable checkpoint is a drift signal rather than a clean pass.
With overwrite: "aboveVariation":
$$changed: whether the span meaningfully changed and the recording (plus its baselines) was refreshed.falsemeans the fresh capture was discarded and the existing file kept.$$changeReasons: why the recording refreshed (drift, added/removed steps, missing file). Present only whenchangedistrue.$$baselineFailures: how many checkpoint baselines Doc Detective couldn’t write during a refresh. It’s present only when at least one failed. The video refreshed but its baselines didn’t fully follow, so the next run treats the mismatch as drift and refreshes both again.
With verify guards:
$$resolutionMatches: whether the video’s dimensions match the expected resolution (±2 pixels). Present only when theresolutionguard ran.$$allBlack: whether black frames cover 95% or more of the video. Present only when thenotBlackguard ran. A violated guard fails the step.
When a span uses checkpoints or "aboveVariation", its checkpoints still run when Doc Detective skips the recording. That happens in a headless run, or when the target already exists under overwrite: "false". If a step fails during the span or the span captures no checkpoints, stopRecord returns SKIPPED with none of the outputs below. Otherwise, stopRecord compares against the committed baselines and writes nothing. Because it seeds no baselines, it omits $$seededBaselines. It reports the other checkpoint outputs above ($$checkpoints, $$maxCheckpointVariation, $$checkpointErrors) plus:
$$stale: whether the committed recording appears stale, meaning its baselines no longer match the current content.truealso returns WARNING and fires a post-run hint that names the fix. For a headless skip, re-run headed. For an existing target, setoverwriteto"true"or"aboveVariation", or remove the file. See Detecting staleness without re-recording.
A skipped stopRecord (no active recording, or a recording that never started) reports no outputs.
Examples
The docs tests run every example below except the null and false example.
Start recording and stop it
This example starts recording, performs an action, and then stops the recording.
Stop with null, or skip the step with false
stopRecord: null stops the most recent recording too, the same as true, and stopRecord: false is an explicit no-op that stops nothing and reports the step as skipped.
Stop a specific recording by name
This example stops a specific recording by name while another recording is still running.
Stop by name using the object form
The object form targets a recording by name too, and behaves the same as the string form.