Cypress - AWS Code Build
Running Cypress in parallel on AWS CodeBuild
TL;DR Check out the example repository:
Executing Cypress 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.
Those workers will use Currents as an orchestration service - each worker will run a subset of spec files and report the results to the cloud dashboard for convenient reporting and troubleshooting.
Prerequisites
To enable parallel runs, please make sure:
you have privileged access to your AWS Account
you have an AWS CodeBuild project created with the batched configuration enabled
Configuration Steps
The first step is to 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.
In the buildspec.yml
file, you need to create multiple workers that will run your Cypress tests in parallel by setting the desired number of workers. See an example with 3 workers below:
You must also include the necessary commands to install Cypress, configure parallel execution, and run your tests.
By distributing tests to each worker, Currents enables faster execution of Cypress tests on AWS CodeBuild. This parallel execution ensures quicker feedback from your browser test suite while leveraging intelligent optimizations to minimize the overall runtime.
Additionally, Currents captures screenshots and videos during the test execution, facilitating troubleshooting efforts.
Example: Cypress Tests in parallel on AWS CodeBuild
Please refer to example repository that demonstrates how to set up AWS Code Build for running cypress tests in parallel using Currents service.
The example config file:
uses 3 workers in matrix mode.
is designed to be executed within a batch build.
Note:
The example uses CODEBUILD_INITIATOR as a CI Build ID. When testing interactively, the CODEBUILD_INITIATOR will be set to the username of the build initiator. When running a batched build, the variable will have the batch build id. Read more about CI Build ID
get your record key from Currents.dev and set AWS CodeBuild Environment Variable variable
CURRENTS_RECORD_KEY
. Read more about Record Keyset the
projectId
incurrents.config.js
- obtain the project id from Currents.devuse CLI arguments to customize your cypress-cloud runs, e.g.:
npx cypress-cloud run --parallel --record --key <your currents.dev key> --group groupA
Here's an example of the demo run in Currents dashboard. Note that 3 runners were used as part of this run:
Last updated