record video only for failed tests using playwright's use.video retain-on-failure option

domain: playwright.dev · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. add use: { video: 'retain-on-failure' } to playwright.config.ts, or the object form { video: { mode: 'retain-on-failure', size: { width, height } } } to also constrain resolution
  2. run the suite normally; Playwright records a video for every test but only keeps the file for tests that ultimately failed
  3. confirm video files are written under the configured outputDir (test-results by default) and attached to failed test entries in the HTML report
  4. for retried tests, verify the video of the failing attempt is retained even if a later retry passes
  5. adjust size in the video option if recordings are too large for CI artifact storage limits

Known gotchas

Related routes

Record video mid-test on demand using Playwright page.screencast.start() and stop() (v1.59+)
playwright.dev · 6 steps · unrated
Record a HAR file in Playwright and replay it for deterministic offline test mocking
playwright.dev · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans