Observability: Traces, Videos and Logs

Observability features like traces, videos and logs turn opaque UI failures into actionable insights. Playwright can capture these artifacts automatically, which is invaluable when debugging in CI.

Using Traces and Videos to Debug Failures

You can enable tracing and video recording in your Playwright configuration or per test, and then upload artifacts from CI for later inspection.

// playwright.config.ts (snippet for trace and video)
import { defineConfig } from '@playwright/test';

export default defineConfig({
  use: {
    trace: 'on-first-retry',
    video: 'retain-on-failure',
  },
});
# After a failed run, open the trace viewer locally
npx playwright show-trace path/to/trace.zip
Note: Traces show step-by-step actions, network events, console logs and DOM snapshots, making it easier to see what happened just before a failure.
Tip: Integrate trace and video artifacts into CI reports so developers can open them directly from failing jobs.
Warning: Recording traces and videos for every passing test can be expensive; use conditional settings like on-first-retry or retain-on-failure.

Logs, console output and network recordings complement traces and can be used selectively for noisy or complex areas.

Common Mistakes

Mistake 1 โ€” Debugging only from textual error messages

This can be slow.

โŒ Wrong: Guessing at timing issues without visual context.

โœ… Correct: Use traces and videos to see exactly what the user would see.

Mistake 2 โ€” Collecting too many artifacts without a plan

This overwhelms storage and people.

โŒ Wrong: Saving all artifacts forever but rarely reviewing them.

โœ… Correct: Capture targeted artifacts on failures and use them actively in triage.

🧠 Test Yourself

How do Playwright traces help with debugging?