Installing Cypress: Step-by-Step Guide
Installing Cypress: Step-by-Step Guide
Cypress is a popular testing tool for modern web applications.
It helps you write and run end-to-end tests in the browser.
Let’s walk through the full installation process.
✅ Prerequisites
Before installing Cypress, you need:
-
Node.js and npm installed
-
You can download from https://nodejs.org
-
To check if it’s installed, run:
-
-
A project folder (use your app or create a new one)
๐ Step 1: Create a Project (if needed)
If you don’t have a project yet:
This creates a new Node.js project.
๐ฆ Step 2: Install Cypress
Use npm to install Cypress:
This installs Cypress as a dev dependency.
๐ Step 3: Open Cypress for the First Time
To open the Cypress Test Runner:
-
This will open the Cypress UI.
-
It will also create a
cypress/
folder with example tests.
๐งช Step 4: Run Your First Test
-
In the Cypress window, click E2E Testing.
-
Choose a browser (like Chrome).
-
Click Start E2E Testing.
-
Select any test from the list and run it.
You’ll see the test run in real time in the browser!
๐ Step 5: Write Your Own Test
Create a file:
cypress/e2e/sampleTest.cy.js
Add a simple test:
Save and run this test from the Cypress runner.
๐งผ Optional: Ignore Example Tests
You can delete the sample tests from:
Keep your own clean structure.
๐ Bonus: Run Cypress in Headless Mode
To run tests without opening the Cypress UI:
It runs in the terminal and outputs test results.
๐ Folder Structure Overview
✅ You’re Done!
Now Cypress is installed and ready to test your app. ๐
๐ก Tip:
-
You can also install Cypress globally, but it's best to keep it project-specific.
-
Use
cypress.config.js
to customize test settings, base URL, timeouts, etc.
Comments
Post a Comment