Next-Gen App & Browser
Testing Cloud
Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles
This Cypress tutorial walks you through everything you need from setup to writing end-to-end Cypress tests along with real-world examples.
Published on: June 17 2025
If you're new to test automation or thinking about moving on from your current testing tools, this Cypress tutorial is a good place to start. Cypress is a JavaScript framework that makes it easy to test modern web applications. You can write tests quickly, debug them visually, and run them as part of your CI pipeline.
Cypress is an open-source, front-end testing framework to test modern web applications. It’s written in JavaScript and runs directly in the browser, allowing you to write unit, integration and end-to-end tests. It also comes with features like real-time reloads, time-travel debugging, and automatic waits which makes it easier to build reliable and maintainable tests.
Cypress can be used to write simple tests and complex tests as well. It also lets you write, run, and debug tests in the browser.
Features:
Note:Run Cypress tests on real browsers and OSes. Try LambdaTest Now!
This section of Cypress tutorial walks you through how Cypress works based on its core architecture.
Cypress lets you write test scripts using JavaScript or TypeScript. It comes with Mocha (a popular JavaScript testing framework) built-in, so you don’t need to install Mocha separately.
Install Cypress using the below command:
npm install cypress --save-dev
After installation, here is how the folder structure looks like:
CYPRESS_FOR_BEGINNERS/
├── cypress/
│ ├── e2e/
│ │ └── lambdatest/
│ │ └── lambdatest_test_spec.cy.js
│ ├── fixtures/
│ │ └── example.json
│ └── support/
├── node_modules/
├── base_reporter_config.json
├── cypress.config.js
├── lambdatest_run.json
├── lambdatest-config.json
├── package-lock.json
└── package.json
In this section of Cypress tutorial, let's look at how to write your first Cypress test.
Step 1: Create a new lambdatest_test_spec.cy.js file under the cypress/e2e/ directory.
Step 2: Open lambdatest_test_spec.cy.js file and write your Cypress test.
The test script automates a user journey on the LambdaTest eCommerce Playground. It opens the login page, logs in with credentials, searches for a product named "VAIO," and verifies that "Sony VAIO" appears in the search results.
describe("Lambdatest Login ",() => {
it("Open the URL", () => {
cy.visit(
"https://ecommerce-playground.lambdatest.io/index.php?route=account/login"
);
});
it("Login into the application", () => {
cy.get('[id="input-email"]').type("[email protected]");
cy.get('[id="input-password"]').type("lambdatest");
cy.get('[type="submit"]').eq(0).click();
});
it("Search the Product", () => {
cy.get('[name="search"]').eq(0).type("VAIO");
cy.get('[type="submit"]').eq(0).click();
});
it("Verify Product after search ", () => {
cy.contains("Sony VAIO");
});
});
You can run Cypress tests using:
You can run Cypress tests in headed mode using the Cypress App.
Step 1: Run the below command to execute Cypress tests locally in headed mode:
npx cypress open
After running the command, the below screen of Cypress App will launch. Select E2E Testing.
Step 2: Choose your preferred browser, and open the Cypress Runner.
Step 3: Click on the lambdatest_test_spec.cy.js file to begin executing the tests. Once complete, you’ll see that all test steps have passed successfully.
By default, Cypress runs in headless mode, so the tests execute in the background without launching a visible browser window.
Run the below command to execute Cypress tests locally in headless mode:
npx cypress run
You can notice in the screenshot below that all test cases were successfully executed in a headless browser.
So far in this Cypress tutorial, we’ve covered how to run Cypress tests locally. Now, let’s explore how to run Cypress tests on a cloud-based grid.
Running Cypress tests in the cloud allows parallel execution at scale, reduces local environment dependency, and speeds up overall test cycles.
AI-native test execution platforms like LambdaTest let you run Cypress tests on a cloud grid. With its Cypress cloud, you can test across real browsers and OS combinations, enabling faster, scalable, and more reliable test execution.
To get started, refer to this guide on Cypress testing with LambdaTest.
To execute your Cypress tests on the cloud grid by LambdaTest, follow the steps below:
Step 1: Get your LambdaTest Username and an Access Key from your LambdaTest Account Settings > Password & Security.
Step 2: Install the LambdaTest Cypress CLI using the below command:
npm install -g lambdatest-cypress-cli
Step 3: In your project root directory, generate a sample config file by running the below command:
lambdatest-cypress init
This creates a lambdatest-config.json file where you’ll specify LambdaTest credentials, browsers and operating systems.
Step 4: Update the generated lambdatest-config.json file with your details. This configuration will run tests in parallel across Chrome, Electron, and Firefox on Windows 11.
{
"lambdatest_auth": {
"username": "your_username",
"access_key": "your_access_key"
},
"browsers": [
{
"browser": "Chrome",
"platform": "Windows 11",
"versions": ["latest-1"]
},
{
"browser": "Electron",
"platform": "Windows 11",
"versions": ["latest"]
},
{
"browser": "Firefox",
"platform": "Windows 11",
"versions": ["latest-1"]
}
],
"run_settings": {
"build_name": "Write First Script In Cypress",
"parallels": 3,
"specs": "./cypress/e2e/lambdatest/*.cy.js",
"ignore_files": "",
"network": true,
"headless": false,
"npm_dependencies": {
"cypress": "13.6.2"
}
},
"tunnel_settings": {
"tunnel": false,
"tunnel_name": null
}
}
When writing this Cypress tutorial, the latest Cypress version is 14.4.1. We used v13.6.2 for our examples. However, you can go ahead with any newer version you're comfortable with.
Step 5: Once your configuration file is ready, run the tests using the below command:
lambdatest-cypress run --sync=true
Step 6: Visit the LambdaTest Web Automation dasard to view your Cypress test results.
When performing Cypress UI testing, here are some of the best practices you can follow:
In this Cypress tutorial, you explored how to use Cypress to test modern web applications. You learned what Cypress is and how it runs directly in the browser. This Cypress tutorial also explained how to perform Cypress automation testing on local grid in both headed and headless modes. You have also learned how to scale your Cypress tests using the LambdaTest cloud grid along with some best practices.
In addition to this Cypress tutorial, you can explore the resources below to further enhance your learning.
Reviewer's Profile
Did you find this page helpful?