Running Your First Test
This quickstart guide will have you running tests in under 5 minutes.Start with UI Tests
Open the Cypress Test Runner for UI tests:This launches Cypress with the UI configuration (
cypress.config.ui.ts).Select a Test
In the Cypress Test Runner:
- Choose your preferred browser (Chrome, Electron, etc.)
- Click on
LoginPageSpec.cy.tsfrom the test list - Watch the test run in the interactive browser
Running Tests Headlessly
For CI/CD or quick verification, run tests in headless mode:Understanding the Output
When you run tests headlessly, you’ll see:Your First UI Test Walkthrough
Let’s examine what happens in the login test:LoginPageSpec.cy.ts
What’s Happening?
Setup
The
beforeEach hook loads test data from users.json and initializes page objects for clean test structure.Navigation
cy.visit('/') navigates to the baseUrl defined in cypress.config.ui.ts (https://www.saucedemo.com/).Actions
Page object methods (
typeUsername, typePassword, clickOnLoginButton) encapsulate element interactions.Running API Tests
API tests are just as easy:Sample API Test
Here’s a simple API test from the framework:GETSpec.cy.ts
API tests use the baseUrl from
cypress.config.api.ts (https://restful-booker.herokuapp.com), so all requests are relative to that endpoint.Available NPM Scripts
The framework provides convenient npm scripts:package.json
cy:open:ui
Opens Cypress Test Runner for UI tests with interactive browser
cy:open:api
Opens Cypress Test Runner for API tests
cy:run:ui
Runs UI tests headlessly (perfect for CI/CD)
cy:run:api
Runs API tests headlessly
Quick Tips
What’s Next?
Project Structure
Understand how files are organized
Page Object Model
Learn the POM pattern in depth
Writing UI Tests
Create your own UI tests
Writing API Tests
Build comprehensive API test suites