azureparallel-processingazure-pipelinescypresscicd

Cypress tests fail to run in parallel mode due to mismatched specs between different runs


We're encountering an issue when running Cypress tests in parallel mode. Specifically, when launching different sets of tests with different tags (like smoke and regression), the system reports that the specs (test files) are mismatched and this causes the test run to fail.

Below are the commands we are using:

  1. For Smoke tests:
"test:smoke": "cypress run --browser chrome --record --key <key> --parallel --ci-build-id $BUILD_BUILDNUMBER --env grepTags=\"smoke\",grepFilterSpecs=true",
  1. For Regression tests:
"test": "cypress run --browser chrome --record --key <key> --parallel --ci-build-id $BUILD_BUILDNUMBER --env grepTags=\"regression\",grepFilterSpecs=true",

The issue

Despite specifying separate test tags, Cypress Cloud claims that the specs do not match between the runs, and this leads to errors. We are unable to run tests in parallel for different test sets.

What we need help with:

Error Log for Regression (but for smoke okay):

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": "114.0.5735.198",
  "differentSpecs": {
    "added": [
     .....
    ],
    "missing": [
     ....
    ]
  }
}

What we've tried so far:


Solution

  • The Cypress cloud is configured by project. Although you consider your repository to be one project and running tests by tag to be two aspects of the same project, the Cypress Cloud project is not conceptually the same.

    In Cypress Cloud a project is a series of runs against the same grouping of tests.

    Further, there is no configuration to record by tag - you must configure two different projects in order to perform two different runs.

    So, to obtain consistent statistics you must treat the two tagged runs as separate projects in the Cloud.

    The reference for cloud "project" setup is here.

    enter image description here

    To handle the separate projectId's for each tag, some code is required in the setup file

    const projectsByTag = {
      'smoke': 'project-id-for-smoke-tests',           // e.g '4b7344',
      'regression': 'project-id-for-regression-tests',
      'default': 'project-id-when-not-passing-a-tag'
    }
    
    module.exports = defineConfig({
      e2e: {
        setupNodeEvents(on, config) {
          const tag = config.env.getTags
          config.projectId = projectsByTag[tag] || projectsByTag.default
          return config
        }
      }
    })