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

How to Run Your First Cypress Test on TestMu AI


If you already write Cypress tests, running your End-to-End (E2E) testing on TestMu AI lets you execute those same tests across multiple browser versions on the cloud instead of a single local browser. You do it by cloning the sample project, setting your credentials, configuring capabilities in lambdatest-config.json, and running the test with the TestMu AI Cypress CLI.

Prerequisites​


Set up the following before you run the test so the CLI can authenticate and locate your project.

Sample repo

Clone the TestMu AI sample Cypress Cloud repo used in this document to follow along with the same files shown here. TestMu AI Cypress Cloud sample repository on GitHub View on GitHub

Complete these three steps to prepare your environment for the first run.

  1. Clone the TestMu AI Cypress-Cloud GitHub repo and navigate to the cloned directory.
Verified
git clone https://github.com/LambdaTest/Cypress-Cloud.git
cd Cypress-Cloud
  1. To run Cypress tests, set your TestMu AI username and access key in the environment variables. You can get them from the TestMu AI Automation Dashboard.

Windows

Verified
set LT_USERNAME="YOUR_LAMBDATEST_USERNAME"
set LT_ACCESS_KEY="YOUR_LAMBDATEST_ACCESS_KEY"

macOS/Linux

Verified
export LT_USERNAME="YOUR_LAMBDATEST_USERNAME"
export LT_ACCESS_KEY="YOUR_LAMBDATEST_ACCESS_KEY"
  1. Install Node.js version 12 or higher. You can download it from the official Node.js website.

Authentication​


TestMu AI reads your credentials in one of three ways. When more than one is set, this order of precedence applies: CLI arguments > lambdatest-config.json > environment variables.

Environment variables: set LT_USERNAME and LT_ACCESS_KEY as shown in Prerequisites.

Env variableAccepted value
LT_USERNAMEYour TestMu AI username
LT_ACCESS_KEYYour TestMu AI access key

lambdatest-config.json: set them under the lambdatest_auth block:

Verified
lambdatest-config.json
"lambdatest_auth": {
"username": "<your username>",
"access_key": "<your access key>"
}

CLI arguments: pass them on the run command (these override the other two methods):

ArgShorthandValue
--username--userYour TestMu AI username
--access_key--akYour TestMu AI access key
Verified
lambdatest-cypress run --username=<your username> --ak=<your access key>

Running Your First Test​


Follow these steps to run your first Cypress test on the TestMu AI platform. The steps cover both Cypress v10 and Cypress v9 projects, so pick the tab that matches your setup as you go.

  1. Install the TestMu AI Cypress CLI using the below command.
Verified
npm install -g lambdatest-cypress-cli
  1. Clone the Cypress kitchen sink repo using the following command.
Verified
# Clone the kitchen sink repo
git clone https://github.com/cypress-io/cypress-example-kitchensink.git

# Go to the cloned directory
cd cypress-example-kitchensink

Once you clone the kitchen sink repo, below will be the structure of your Cypress project.

Verified
...
cypress
|-- fixtures
|-- e2e
|-- support
cypress.config.js
...
  1. Install the npm dependencies by passing the below command.
Verified
npm install
  1. Create the lambdatest-config.json file that contains configurations like auth, capabilities, and test settings needed to run successfully on TestMu AI.

Use init command to generate the sample configuration files.

Verified
lambdatest-cypress init --cv=10

Once you run the above command, below is the project structure for the lambdatest-config.json file.

Verified
{
"lambdatest_auth": {
"username": "<your TestMu AI username>",
"access_key": "<your TestMu AI access key>"
},
"browsers": [
{
"browser": "Chrome",
"platform": "Windows 10",
"versions": [
"latest-1"
]
},
{
"browser": "Firefox",
"platform": "Windows 10",
"versions": [
"latest-1"
]
}
],
"run_settings": {
"cypress_config_file": "cypress.config.js",
"reporter_config_file": "base_reporter_config.json",
"build_name": "build-name",
"parallels": 1,
"specs": "./*.cy.js",
"ignore_files": "",
"network": false,
"headless": false,
"npm_dependencies": {
"cypress": "10.0.0"
}
},
"tunnel_settings": {
"tunnel": false,
"tunnel_name": null
}
}
  1. Pass the below command to run the test.
Verified
lambdatest-cypress run
  1. Visit the TestMu AI Automation dashboard to view your test results. The CLI also prints a link to view the Cypress test build.
TestMu AI Automation Dashboard showing a passed Cypress test with command logs and a video of the run

Run Your Tests in Parallel​


Once your first test runs, you can execute multiple Cypress tests at once to cut total run time. Configure parallel execution in either of two ways.

Using the CLI: pass the --parallels flag with the number of sessions:

Verified
--parallels <number of parallel sessions>

For example, to run your Cypress tests on 5 parallel sessions:

Verified
lambdatest-cypress run --parallels 5

Using lambdatest-config.json: set the parallels key under run_settings:

Verified
{
"run_settings": {
"parallels": 5
}
}
NOTE

The number of parallel tests running at a time depends on the concurrency plan of your TestMu AI account. If you request more parallel tests than your plan allows, the extra tests are queued and run as running tests finish. For example, on a 5-session plan, running 50 tests runs 5 at a time and queues the other 45.

Testing Locally Hosted or Privately Hosted Projects​


To test locally hosted websites on the TestMu AI platform, set up the TestMu AI tunnel and run commands using the CLI, or use UnderPass, the TestMu AI GUI-based desktop app. Once the TestMu AI tunnel or UnderPass is set up and started, you can use Cypress to test locally hosted websites.

Next, activate the tunnel capability in the lambdatest-config.json file under the tunnel_settings section as shown below.

Verified
  "tunnel_settings": {
"tunnel": true,
"tunnel_name": "LT_Tunnel"
}

You can provide the name of the TestMu AI tunnel as per your requirements.


Continue with the guides below to generate, configure, and scale your Cypress runs on TestMu AI.

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