Skip to main content

Setup & First Test

Cypress is a JavaScript-native E2E testing framework that runs directly in the browser — no WebDriver protocol, no separate driver process. Tests are fast, reliable, and easy to debug.

Installation

npm install --save-dev cypress
# or
yarn add --dev cypress

Add a script to package.json:

{
  "scripts": {
    "cypress:open": "cypress open",
    "cypress:run": "cypress run"
  }
}

Run npx cypress open once to generate the default folder structure.

Folder Structure

cypress/
├── e2e/            your test files go here
├── fixtures/       static test data (JSON)
├── support/
   ├── commands.js    custom commands
   └── e2e.js         runs before every test file
cypress.config.js

Your First Test

Ctrl+Enter
HTML
CSS
JS
Preview

Run headlessly in CI:

npx cypress run --spec "cypress/e2e/homepage.cy.js"

The Cypress Test Runner

Cypress test runner simulation
Ctrl+Enter
HTML
CSS
JS
Preview

cypress.config.js

Ctrl+Enter
HTML
CSS
JS
Preview

With baseUrl set, cy.visit('/login') resolves to http://localhost:3000/login.