Comment on page

Playwright - AWS Code Build

Running Playwright Tests in Parallel on AWS CodeBuild and Currents
TL;DR Check out the example repository:
Executing Playwright tests in parallel on AWS CodeBuild can significantly reduce the overall run duration. AWS CodeBuild supports Batched Build in matrix mode for launching several workers in parallel.
Use AWS CodeBulld Matrix mode to run Playwright tests in parallel with Currents. 1 batch job (1) triggering 3 parallel build jobs (2).
Parallel Playwright Tests recorded to Currents dashboard from AWS CodeBulld


To enable parallel runs, please make sure that you have privileged access to your AWS Account and that you can create/modify an AWS CodeBuild Project.


Obtain Currents Credentials

Create an organization, and get Record Key and Project ID at

Create buildspec.yml

Create a buildspec.yml file in the root directory of your application's source code repository. This file defines the build and test steps for your application.
Set the Project ID for pwc command, for example:
npx pwc --project-id <project_id> --key $CURRENTS_RECORD_KEY --ci-build-id $CODEBUILD_INITIATOR --shard $WORKER/3
The example uses pwc CLI command to run the tests. You can use npx playwright test command and configure @currents/playwright as a reporter. Please refer to the documentation.
The buildspec.yml file uses matrix mode to start 3 containers for running the test in parallel. Each container will have the environment variable WORKER set to 1,2,3 correspondingly, we use it to configure Playwright Sharding --shard $WORKER/3
## buildspec.yml
version: 0.2
fast-fail: false
- buildspec.yml
- 1
- 2
- 3
nodejs: 18
# install playwright and its dependencies
- npm ci
- npx playwright install
- npx playwright install-deps
# Optionally, set COMMIT_INFO variables to override the default values. See
# - export COMMIT_INFO_BRANCH="$(git rev-parse HEAD | xargs git name-rev |
# cut -d' ' -f2 | sed 's/remotes\/origin\///g')"
# - export COMMIT_INFO_MESSAGE="$(git log -1 --pretty=%B)"
# - export COMMIT_INFO_EMAIL="$(git log -1 --pretty=%ae)"
# - export COMMIT_INFO_AUTHOR="$(git log -1 --pretty=%an)"
# - export COMMIT_INFO_SHA="$(git log -1 --pretty=%H)"
# - export COMMIT_INFO_REMOTE="$(git config --get remote.origin.url)"
# update shard details according to the overall # of containers
- npx pwc --project-id <project_id> --key $CURRENTS_RECORD_KEY --ci-build-id $CODEBUILD_INITIATOR --shard $WORKER/3
Save the Record Key as CURRENTS_RECORD_KEY Environment variable. It is strongly recommended to use your Record Key in a secure secrets storage. Please refer to the detailed guide, here is an overview of the steps:
  • Create a new entry in AWS Secrets Manager with the Record Key. Please note that the generated secret is a JSON document, you should note the json_key of the actual record key value and use it later.
  • Get the secret ARN
  • Update the Build Project environment variables as follows:
    • Variable name: CURRENTS_RECORD_KEY
    • Variable value: the ARN of previously created secret + json_key, for example: <secret-arn>:<json-key>
  • Update the IAM execution role to allow reading of previously created secret

Configure AWS Project

Configure AWS-specific project settings like IAM execution policy, resources class and so on. Please refer to AWS CodeBuild documentation for details to explore possible configuration settings.
Configure Source Batch Mode
  • Set the Project Setting > Edit Source
  • Configure the repository details, the events that should trigger new builds
  • Configure Primary source webhook events > Build Type to Batch build to start 3 parallel workers in matrix mode

Example: Triggering Parallel Playwright AWS CodeBuild

This example repository showcases running Playwright tests on AWS CodeBuild in parallel while using Currents as the reporting dashboard. It has an example AWS CodeBuilld Project configuration.
Example of triggering an AWS CodeBuild Playwright Tests via a commit