feat(run)!: video modes on the config, targets, the CLI, and tests, with provider recordings
What and why
Video had one run-wide switch (artifacts.kinds: ['video'] or --video) and a retain flag. This PR makes it a first-class, engine-agnostic option, adds retry-aware modes, and lets hosted services supply the recording.
How other tools do it (the research that shaped the API)
| Tool | Where it is set | Modes | Per-test |
|---|---|---|---|
| Playwright | config, project, test.use per file or describe | off, on, retain-on-failure, on-first-retry, plus 3 added in 1.61 | describe only, because the video fixture is worker-scoped |
| Cypress | config | on/off, delete in after:spec | none |
| Detox | config, --record-videos | none, failing, all | none |
| Maestro, Appium | in-flow start/stop | explicit | yes |
| BrowserStack, Sauce, LambdaTest, Browserbase | session capability | on, or videoUploadOnPass | per session; a URL after the session ends |
| Kernel, Limrun, Anchor | mid-session start/stop API | explicit | per session; bytes or a URL |
Other runners bind recording to context or session creation, so a per-test switch would cost them a new worker or session. e2e starts and stops recording per attempt through the engine hooks, so a per-test override costs nothing here.
The API
export default {
video: 'retain-on-failure', // config default
targets: [
{ name: 'web', engine: web({ url }) },
{ name: 'kernel', engine: web({ url, browser: kernel() }), video: 'on-first-retry' },
],
} satisfies E2EConfig;
test('checkout', { video: 'on' }, async ({ app, screen }) => { /* ... */ }); // innermost wins
- Modes:
off,on,retain-on-failure,on-first-retry. They are Playwright's first four, and they cover the two patterns every tool converges on: record everything and keep failures, or record only the retry. - Precedence, lowest to highest: the config's
video, the target's,--video [mode], then a test or describe. Inside a serial group the group decides, as it does forretries. - Breaking:
artifacts.kinds: ['video']andartifacts.videoare removed, and using them isINVALID_CONFIGwith the new spelling in the message. - Preflight:
UNSUPPORTED_ARTIFACTis raised only when a test that runs would actually record on an engine that cannot. - Step captions were prototyped here and taken out to be designed properly in #636 (the prototype is on
oskar/video-captions-prototype). - Local screencast:
web({ video: { size, quality } }).
Provider recordings, engine-agnostic
flowchart LR
A[attempt starts video] --> B{provider has record?}
B -- yes --> C[provider.record lease -> ProviderRecording]
B -- no --> D[engine capture: Playwright screencast / agent-device]
C --> E[stopProviderRecording: file in video/ or http link]
D --> F[VideoSegment files]
E --> G[report: path or url]
F --> G
e2e/engineexportsProviderRecording,ProviderRecordContext,isProviderRecording, andstopProviderRecording.VideoSegmentbecomesVideoFile | VideoLink.BrowserProvider.recordandDeviceProvider.recorduse the same seam. On mobile the worker now learns its lease id, so a provider can recover its lease.- Kernel replays are the first provider that records, saved as
video/replay.mp4. Headless browsers andreplay: falsefall back to the screencast. - Schema:
report-1artifacts gain an optionalurl(http(s) only), with both fixtures updated. The run page links a hosted video to its own URL.
Verified
Ran it locally: yes
/tmp/video-smoke, a fresh project using the packed tarballs, a local app, andretries: 1. Each target hasplaces an order(passes),fails on purpose(fails on both attempts), andkeeps quiet(video: 'off'):
| Target | passes | fails (2 attempts) | video: 'off' |
|---|---|---|---|
video: 'on' | kept | both kept | nothing |
web({ video: { size: 640x360 } }) | kept, 640x360 | both kept | nothing |
retain-on-failure | dropped | both kept | nothing |
on-first-retry | nothing | attempt 1 only | nothing |
-
Real Kernel: an agent test with
video: 'on'producedvideo/replay.mp4, the Kernel replay of the whole browser window. -
e2e mcpon Kernel:start_recording/stop_recordingsaved a 1920x1080 Kernel replay to.e2e/videos/<session>/1-todo-demo.mp4. On a local browser the same tools saved the page screencast as.webm. -
After taking captions out, the
/tmp/video-smokerun again kept every video underonand only the failed ones underretain-on-failure, with no.vttwritten and nocaptionsfield. -
A fresh-context review found 8 issues and all are fixed (the eighth was about captions, which are now out):
- Provider URLs and timestamps normalized to the schema's shapes.
--videono longer hides an invalid target mode.videorejected on a describe nested in a serial group.- One list of modes.
- One shared recording check for web and mobile.
- A mobile lease's own
leaseId. - The changeset note for stores.
-
Follow-ups, not in this PR:
expiresAton links, because signed URLs expire.- Handing the attempt's verdict to a provider's stop, so
retain-on-failurecan delete the remote recording. - More Playwright modes if someone asks for them.
Checklist
- Changeset added (
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only. - Breaking change: title carries
!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md). Removed without a deprecation window, by decision. - Docs updated in the same PR: the
docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it. - Contract change: emitted
.d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures. - Engine contract change (
e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.
https://github.com/user-attachments/assets/819fe714-79ad-4d17-b9ac-a8a0061e79d2