DEV Community

Shell QA
Shell QA

Posted on

Setting Up Playwright Automation in CI/CD: Harness & GitHub Actions Pipeline Guide

Running Playwright automated test suites smoothly inside continuous integration (CI) environments requires a clean pipeline setup—handling Node environments, browser dependency installation, execution, and artifact publishing.

Below is a practical configuration reference for setting up Playwright tests using Harness YAML, along with core pipeline considerations.

Harness Pipeline Configuration

If your organization uses Harness for CI deployment, here is a conceptual pipeline snippet covering the required execution stages:

pipeline:
  stages:
    - name: checkout
      steps:
        - checkout
    - name: setup-node
      steps:
        - setup: node 20
    - name: install
      steps:
        - run: npm ci
    - name: install-browsers
      steps:
        - run: npx playwright install --with-deps
    - name: run-tests
      steps:
        - run: npm run test:ci # or npm run test:parallel
      env:
        API_BASE_URL: ${{SECRETS.API_BASE_URL}}
        API_TOKEN: ${{SECRETS.API_TOKEN}}
    - name: publish-artifacts
      steps:
        - upload: reports/
Enter fullscreen mode Exit fullscreen mode

Note: For GitHub Actions users, equivalent step-by-step logic can be placed in .github/workflows/playwright.yml.

Key Implementation Guidance

  • Secret Binding: Replace placeholder secret references (${{SECRETS.*}}) with your platform's native secret store bindings or environment key integrations.

  • Browser Binary Management: Ensure npx playwright install --with-deps has outbound internet access during build steps, or pre-bake required browser binaries into pre-cached CI base Docker images to reduce run times.

  • Artifact Capture: Always publish test execution reports (HTML reports, traces, screenshots) as post-execution build artifacts for quick failure triage.

Top comments (0)