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:
"test:smoke": "cypress run --browser chrome --record --key <key> --parallel --ci-build-id $BUILD_BUILDNUMBER --env grepTags=\"smoke\",grepFilterSpecs=true",
"test": "cypress run --browser chrome --record --key <key> --parallel --ci-build-id $BUILD_BUILDNUMBER --env grepTags=\"regression\",grepFilterSpecs=true",
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.
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:
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.
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
}
}
})