For AI agents and LLMs: a machine-readable index is available at llms.txt. A plain-Markdown version of any documentation page is available by appending .md to its URL.
Skip to main content

Configuring Cypress Test Execution

You can specify Cypress CLI flags to run on TestMu AI in two ways:

  1. Adding the CLI flag details in lambdatest-config.json file
  2. Using the CLI
tip

If a glob pattern path is passed in the specs flag using CLI, you must enclose it within double quotes as shown: lambdatest-cypress-cli run --env=stage --verbose --specs "./cypress/integration/examples/*"

Cypress Config File​

Using lambdatest-config.json​

You can use the cypress_config_file key in run_settings option to specify the Cypress configuration file.

NOTE : Cypress 10 and above versions automatically identify the cypress.config.js file in the project. Therefore, you don't need to specify the cypress_config.js capability.

Verified
lambdatest-config.json
{
"run_settings": {
"cypress_config_file": "cypress.json",
"video": true
}
}

Using CLI​

You can specify the Cypress configuration file using the below CLI flag with run command.

FlagPurposeType
--ccf, --cypress-config-filePath of the config fileString

Specifying Spec Files​

Using lambdatest-config.json​

You can use the specs key in run_settings option to specify the Spec files.

Verified
lambdatest-config.json
{
"run_settings": {
"specs": "**/*.cy.js",
}
}

Using CLI​

You can specify the Spec files using the below CLI flag with run command.

FlagPurposeType
-s, --specsPath of the spec file or directory or patternString

Exclude Specs Files​

You can use the exclude_specs key in run_settings option to specify the spec files that you want to exclude from the test execution.

Verified
lambdatest-config.json
{
"run_settings": {
"exclude_specs": "./examples/assertion.spec.js, ./examples/connectors.spec.js",
}
}

Geolocation​

Using lambdatest-config.json​

You can use the geo_location key in run_settings option to specify the Spec files.

Verified
lambdatest-config.json
{
"run_settings": {
"geo_location": "<country_code>",
}
}

Using CLI​

You can specify the geolocation files using the below CLI flag with run command.

FlagPurposeType
--geo, --geo_locationPass the Geo country codeString

Resolution​

Using lambdatest-config.json​

Use the resolution key in run_settings option to specify the resolution.

Verified
lambdatest-config.json
{
"run_settings": {
"resolution": "1024x768",
}
}

Using CLI​

You can specify the system's resolution using the below CLI flag with run command.

FlagPurposeType
--resPass the resolutionString

It will change the resolution of the system but the viewport in which Cypress launches the website is controlled by Cypress.

Supported resolutions: 1024x768, 1280x960, 1280x1024, 1600x1200, 1920x1080, 2048x1536, 2560x1440

Excluding Files From Test Uploads​

Using lambdatest-config.json​

You can use the ignore_files key in run_settings option to ignore or exclude any particular files while uploading your tests.

Verified
lambdatest-config.json
{
"run_settings": {
"ignore_files": "<glob_pattern>",
}
}

Using CLI​

Specify the files that you want to exclude using the below CLI flag with run command.

FlagPurposeType
--if, --ignore_filesFiles to ignore in the zip projectString

Max Duration for Test Session Timeout​

When running tests, if you encounter a situation where a particular test is running for an extended period and causing other parallel tests to be blocked, in this case, you can use the max duration flag to mitigate the issue. This flag allows you to specify a maximum time limit for the test to run before it is automatically stopped, thus freeing up resources for other tests to execute.

The valid input for max_duration must be an integer, and it can only be within the range of 2 to 240 minutes.

Using lambdatest-config.json​

You can use the max_duration key in run_settings option to specify the session timeout.

Verified
lambdatest-config.json
{
"run_settings": {
"max_duration":2
}
}

Using CLI​

You can specify the timeout using the below CLI flag with run command.

FlagPurposeType
--max_durationidle timeout of a test sessionInteger

Organizing Tests​

You can name your test cases and categorize your Cypress builds by build number, build name, test and build tags for easier analysis. Use the following keys to organize your tests.

KeyDescriptionType
build-nameRepresent the name of the build for your testString
project-nameRepresents the name of your projectString
tagsGroup your testsString

Example:

Verified
lambdatest-config.json
{
"run_settings": {
"build-name": "Cypress 10 Demo",
"project-name": "DemoTest",
"tags": "Sprint1",
}
}

Headless Browser​

You can run Headless tests with Cypress by the headless key to true.

KeyDescriptionType
headlessRun test in Headless modeBoolean

Example:

Verified
lambdatest-config.json
{
"run_settings": {
"headless": "true",
}
}

Capture Network Logs​

You can generate Network logs with Cypress by setting the network key to true.

KeyDescriptionType
headlessRecord network packets while the test is runningBoolean

Example:

Verified
lambdatest-config.json
{
"run_settings": {
"network": "true",
}
}

NPM Package Dependencies​

In order to run your tests on TestMu AI, we refer to your package.json and use those dependencies and devDependencies. Since, package.json may contain several dependencies which may not be required to run your Cypress tests. We recommend to use npm_dependencies parameter to list down the required dependencies to run your test, because it will reduce your build time on TestMu AI.

Below are the ways through which TestMu AI detects the dependencies which has to be installed before running the test on TestMu AI.

Using npm_dependencies​

Inside run_settings of lambdatest-config.json, you can provide the list of NPM dependencies:

Verified
lambdatest-config.json
"run_settings": {
"npm_dependencies": {
"cypress": "9.0.0",
},
},

Using package.json​

TestMu AI will automatically detects the dependencies that has to be installed from package.json.

Verified
package.json
"devDependencies": {
"cypress": "9.2.1",
"eslint": "7.0.0",
"eslint-plugin-json-format": "2.0.1",
"eslint-plugin-mocha": "5.3.0",
},
note

It's recommended to use npm_dependencies instead of package.json because package.json may contain the dependencies which are not actually used while running the Cypress tests and also, installing these unwanted dependencies will increase the build time.

Specific Node Version​

TestMu AI allows you to specify the Node.js version for running your tests using the useNodeVersion capability in the run_settings section of the lambdatest-config.json file. This capability provides greater flexibility and ensures compatibility with your project's dependencies and environment.

Supported Versions are 18, 20 and 22. The exact version will be used are 18.17.1, 20.18.0, and 22.11.0 respectively

Verified
lambdatest-config.json
"run_settings": {
"useNodeVersion":"20"
}

Terminal First Testing With Kane CLI

Natural language browser & mobile app tests right from terminal.

×
Schedule Your Personal Demo
Kane CLI terminal

Help and Support

Related Articles