Guides

Playwright export

What the exported spec contains and how to run it in your own CI.

Every test case exports as a self-contained @playwright/test spec from the run page or from the API. It is generated code: read it, edit it, keep it. The exporter is deterministic, so regenerating after a change produces the same shape.

What is inside

  • Role-based locators with exact names; test ids where recorded.
  • A ready() helper built from the environment's readiness signal.
  • Console, page-error and response collectors that fail the test at the end.
  • Per-step timings attached to the report.
  • An optional axe scan that runs if @axe-core/playwright is installed.
  • An aria snapshot assertion of the final page when one was captured.

Secrets

A step that typed {{secret:password}} exports as secret("password"), which reads SECRET_PASSWORD from the environment and throws if it is missing. Values are never in the file.

Authentication

When the environment has a test-only session mint endpoint, the export authenticates once per worker and reuses storage state. Note that storage state captures cookies and localStorage only; if your app keeps its token in sessionStorage, seed it with an init script instead.

Run it

BASE_URL=https://staging.example.com SECRET_PASSWORD=… npx playwright test tc-0001.spec.ts
Playwright export · Handoff