Cypress Parallelization Setup
DeploySentinel can help speed up test runs by orchestrating your CI machines to run your test suite concurrently and load balanace test files across multiple machines.
Install
Install the debugger package to access the ds
CLI if you haven't already.
npm install -D @deploysentinel/cypress-debugger
For Cypress v12 and Above
If running Cypress v12 or above, you'll need to additionally install the
@deploysentinel/cypress-parallel
package to enable parallelization.
Additionally, ensure that the @deploysentinel/cypress-debugger
package is
updated to at least version 0.8.3
.
npm install -D @deploysentinel/cypress-parallel
Additionally, within your plugin file you'll need to initialize the parallelization plugin:
cloudPlugin(on, config);
Full Example:
const { defineConfig } = require('cypress');
const { cloudPlugin } = require('@deploysentinel/cypress-parallel/plugin');
const dsPlugin = require('@deploysentinel/cypress-debugger/plugin');
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
// Existing DeploySentinel Debugger Plugin
[on, config] = dsPlugin(on, config);
// New DeploySentinel Parallelization Plugin
cloudPlugin(on, config);
},
},
});
Note: Running Cypress in headed mode will not work with parallelization (by
default, cypress run
runs in headless mode). Contact support for more
information if headed support is required.
Define a Project ID
If you haven't already, you'll need to define a
project ID (opens in a new tab)
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.
Use ds
CLI Instead of cypress
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