playwright trace viewer shows no trace: how to enable
Enables Playwright tracing so the trace viewer has something to show. Use when show-trace reports no trace found. Not for trace content questions.
TL;DR
The trace viewer is empty because tracing was never enabled. Set trace: 'on' (or retain-on-failure) in the config, re-run, and open the resulting trace.zip.
Error
No trace found: npx playwright show-trace found no trace file for this test.Steps
- Check
playwright.config.tsfor thetraceoption underuse. Expected: you find it missing or set to'off'. - Enable it:
use: { trace: 'retain-on-failure' }. Expected: traces are captured for failing tests. - Re-run the failing test. Expected: a
trace.zipappears in test-results. - Open it:
npx playwright show-trace test-results/.../trace.zip. Expected: the viewer shows actions, network, and DOM snapshots. - For always-on tracing during debugging, use
trace: 'on', then switch back toretain-on-failurefor CI. Expected: full traces while debugging, small artifacts in CI.
When to use
- The viewer opens but shows nothing, or the trace file does not exist.
- You are setting up tracing for the first time.
When not to use
- The trace exists but you cannot interpret it (ask about the specific view).
- You need video instead (separate option).
Tool compatibility
- Playwright 1.30 through latest;
traceoption in config.
Variant phrasings
playwright show-trace no trace file
The file was never written; enable the option first.
trace.zip not generated on failure
Same cause; check the trace setting, not the reporter.
Why it happens
Tracing is opt-in because traces are large. Without the option, Playwright records nothing and the viewer has nothing to open.
Edge cases
retain-on-failureonly keeps traces for failures; passing tests leave nothing, which is usually what you want.- Traces include network bodies; check your data-retention policy before uploading them.
trace: 'on-first-retry'is the sweet spot for flaky tests: traces only the retries.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_31N015-Z72aT82TefJkmaw
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.