Cypress Parallelization Setup

Last Updated on Aug 2, 2022

1. Install @deploysentinel/cypress-debugger

Only required if the debugger is not already installed.

The ds command to enable parallelism is only available when the cypress debugger package is installed.

npm install -D @deploysentinel/cypress-debugger

2. Define a Project ID

If you haven't already, you'll need to define a project ID inside your Cypress config file, or alternatively it can be defined via the CYPRESS_PROJECT_ID environment variable.

The project ID can be any 6 character string (ex. "000000"), as our API routes calls based on your API key alone and not the project ID. However, a project ID must be defined in your configuration as part of being compatible with Cypress's parallelization API.

3. Use ds Instead of cypress When Running Tests

Instead of cypress run --record --parallel use ds run --record --parallel (both --record and --parallel flags are required for parallelism to be enabled). Additionally, you'll need to ensure that the CYPRESS_DEPLOYSENTINEL_KEY environment variable is set.

Local Example

CYPRESS_DEPLOYSENTINEL_KEY=YOUR_API_KEY CYPRESS_PROJECT_ID=000000 npx ds run --record --parallel --ci-build-id JUST_TESTING_LOCALLY

Github Action Step Example:

- name: Run Tests in Parallel
  uses: cypress-io/github-action@v4
  with:
    command: npx ds run --parallel --record --headless --browser chrome
  env:
    CYPRESS_DEPLOYSENTINEL_KEY: ${{ secrets.CYPRESS_DEPLOYSENTINEL_KEY }}

CircleCI Step Example:

orbs:
  cypress: cypress-io/cypress@1
workflows:
  build:
    jobs:
      - cypress/install:
          build: npm run build
      - cypress/run:
          requires:
            - cypress/install
          command: npx ds run --parallel --record --headless --browser chrome
          parallelism: 4