Trace viewer
Before I discovered traces, I was manually adding page.screenshot() calls everywhere to debug failures. Now I just open the trace — it records every action, network request, console error, and a DOM snapshot you can interact with. Time travel through your test.
Enable tracing in config
Add trace: 'on-first-retry' to the use section of your config. This records a trace only when a test fails and is retried — so you get the trace exactly when you need it, and don't waste disk space on passing tests.
To force a trace locally for debugging, run with --trace on.
Open the trace — two ways
After a run with traces, Playwright creates a trace.zip file in test-results/. Two ways to open it.
What's inside the trace
The trace viewer has several panels. The key ones I use for debugging:
My debugging workflow with traces
When a test fails in CI and I can't reproduce it locally, the trace is the only window into what actually happened. Here's how I read it: