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.

  1. In playwright.config.ts, set screenshot: 'only-on-failure' and trace: 'retain-on-failure' so that screenshots and traces of failing tests are saved to the test-results folder. 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',
      },
    });
  2. Add a PublishPipelineArtifact step to the pipeline YAML, with condition: 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.