Skip to main content
New to Testkube? Unleash the power of cloud native testing in Kubernetes with Testkube. Get Started >

Sharded Playwright Example

info

This Workflows functionality is not available when running the Testkube Agent in Standalone Mode - Read More

Testkube has built-in support for parallelizing any testing tool - check out the Parallelization documentation for details and examples.

The below example shows how to distribute ("shard") a set of Playwright tests across a configurable number of nodes and aggregate individual reports into a single report that is available as an artifact.

The example below:

  • Load the Git repository with Playwright test (content)
  • Install the project dependencies (steps[0].shell)
  • Run the Playwright tests split to 2 shards (steps[1].parallel)
    • Reserve 1 CPU and 1GB RAM for each shard (steps[1].parallel.container.resources)
    • Copy the repository and node_modules inside (steps[1].parallel.transfer)
    • Run Playwright test - with blob reporter, and with specific shard segment (steps[1].parallel.shell)
    • Fetch the Blob reporter's data to corresponding directory on Execution's pod (steps[1].parallel.fetch)
  • Merge the reports using Playwright's tooling (steps[2].shell)
  • Save the merged report as an artifact (steps[2].artifacts)
Sharded Playwright Workflow
apiVersion: testworkflows.testkube.io/v1
kind: TestWorkflow
metadata:
name: example-sharded-playwright-with-merged-report
spec:
content:
git:
uri: https://github.com/kubeshop/testkube
paths:
- test/playwright/executor-tests/playwright-project
container:
image: mcr.microsoft.com/playwright:v1.38.0-focal
workingDir: /data/repo/test/playwright/executor-tests/playwright-project
steps:
- name: Install dependencies
shell: 'npm install --save-dev @playwright/test@1.38.0 && npm ci'
- name: Run tests
parallel:
count: 2
transfer:
- from: /data/repo
fetch:
- from: /data/repo/test/playwright/executor-tests/playwright-project/blob-report
to: /data/reports
container:
resources:
requests:
cpu: 1
memory: 1Gi
shell: |
npx playwright test --reporter blob --shard {{ index + 1 }}/{{ count }}
- name: Merge reports
condition: always
shell: 'npx playwright merge-reports --reporter=html /data/reports'
artifacts:
paths:
- 'playwright-report/**'

The log output from the Playwright Framework execution:

Shared Playwright Log Output