A test failed in CI. What happened? In Selenium, you have a stack trace and maybe a screenshot. In Playwright, you have the Trace Viewer -- a full timeline of everything that happened during the test. Think of it as a flight recorder for your tests.
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
// Record trace for every test (good for debugging)
trace: 'on',
// Or record only on failure/retry (good for CI)
// trace: 'on-first-retry',
// trace: 'retain-on-failure',
},
});# Run tests with tracing
npx playwright test
# Open trace viewer for a failed test
npx playwright show-trace test-results/my-test/trace.zip
# Or view traces online (no install needed)
# Upload trace.zip to trace.playwright.devUse "trace: 'on-first-retry'" in CI. This records a trace only when a test fails and retries, saving storage while still giving you full debugging data for failures. It is the sweet spot between "always record" and "never record".
Key Point: Trace Viewer is a flight recorder for your tests. Screenshots, DOM snapshots, network logs, and console output -- all in one timeline.