Playwright Pipelines
This document describes standards for running Playwright tests in pipelines.
Standard Metadata
- Area: Playwright
- Owner: Technical Leadership group
- Last reviewed: 2026-10-07
- Next review due from: 2026-12-01
- Enforcement: Code review
- Status: Active
Playwright pipelines should publish screenshots and traces of failing tests · PW-09.1 · SHOULD · TEST
Configure Playwright to take screenshots and traces of failing tests, and publish them from the pipeline. This improves debugging and makes it easier to raise bug cards for regressions.
-
In
playwright.config.ts, setscreenshot: 'only-on-failure'andtrace: 'retain-on-failure'so that screenshots and traces of failing tests are saved to thetest-resultsfolder. Traces show every step, network call and page snapshot of a failing test.export default defineConfig({ use: { screenshot: 'only-on-failure', trace: 'retain-on-failure', }, }); -
Add a
PublishPipelineArtifactstep to the pipeline YAML, withcondition: always()so that it runs even when tests fail:- task: PublishPipelineArtifact@1 displayName: 'Publish Failure Screenshots - ${{ parameters.environmentName }}' inputs: targetPath: test-results artifact: playwright-E2E-failure-screenshots publishLocation: 'pipeline' condition: always()
Traces can capture credentials as they are typed, so only publish them as pipeline artifacts, as described in do not commit or log credentials.