I am setting up cypress e2e tests in an NX mono repo for the first time. I cannot get the tests to run in parallel. Currently, there are two apps: App-A and App-B in our repo. We also have two cypress apps: App-A-e2e and App-B-e2e.
Here is what our GitHub actions workflows look like:
main.yaml (only including the cypress jobs)
cypress-staging-run:
needs: deploy-staging
uses: ./.github/workflows/cypress-run.yaml
with:
test_environment: staging
cypress_tag: staging
secrets: inherit
cypress-production-run:
needs: deploy-production
uses: ./.github/workflows/cypress-run.yaml
with:
test_environment: production
cypress_tag: production
secrets: inherit
cypress-run.yaml
name: Run Cypress Tests
on:
workflow_call:
inputs:
test_environment:
required: true
type: string
cypress_tag:
required: true
type: string
secrets:
MY_SECRET:
required: true
jobs:
cypress-run:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Derive shas used for base and head required by nx affected commands
uses: nrwl/nx-set-shas@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: yarn setup:ci
- name: Cypress Run
uses: cypress-io/github-action@v5
with:
command: yarn e2e:ci --configuration=${{ inputs.test_environment }} --tag ${{ inputs.cypress_tag }}
**Tried adding parallel: true here, but it was not recognized- in CI showed parallel: false**
env:
CYPRESS_fileConfig: ${{ inputs.test_environment }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MY_SECRET: ${{ secrets.MY_SECRET }}
package.json
"scripts": {
"e2e:ci": "nx affected --target=e2e",
I tried adding --parallel and -- --parallel to the script or adding parallel: true to each app's project.json:
"targets": {
"e2e": {
"executor": "@nrwl/cypress:cypress",
"options": {
"cypressConfig": "apps/app-a-e2e/cypress.config.ts",
"testingType": "e2e",
"browser": "chrome",
"record": true,
"key": "record key here",
"parallel": true
},
In both cases, I get the same error:
You passed the --parallel flag, but we do not parallelize tests across different environments.
This machine is sending different environment parameters than the first machine that started this parallel run.
The existing run is: "URL here"
In order to run in parallel mode each machine must send identical environment parameters such as:
- specs
- osName
- osVersion
- browserName
- browserVersion (major)
This machine sent the following parameters:
{
"osName": "linux",
"osVersion": "Ubuntu - ",
"browserName": "Chrome",
"browserVersion": "111.0.5563.146",
"differentSpecs": {
"added": [
"src/e2e/app-a-test-1.cy.ts",
"src/e2e/app-a-test-2.cy.ts",
"src/e2e/app-a-test-3.cy.ts",
],
"missing": [
"src/e2e/app-b-test-1.cy.ts"
]
}
}
So it seems like because app-a-e2e and app-b-e2e have different tests I can't run them in parallel. I then tried splitting up my cypress run into two separate jobs in the hopes that I could run App-A-e2e tests in parallel and then when that is done run App-B-e2e tests in parallel, but I got the same error. I feel like I have read every documentation I can find, but I'm still unclear on how to run the tests in parallel. Any help is appreciated.