Keyboard Shortcuts N Next post
P Previous post
S Save / unsave
R Read aloud
T Toggle theme
/ Focus search
Esc Close panels
🔥
Ready to read...
Cypress

Cypress Complete Handbook Course With IM CSEIAN | IMCSEIAN

Reviewed & accurate
AI Summary
Cypress Complete Handbook Course With IM CSEIAN — Interactive Tutorial Series
Cypress Course
0% · 0/9

The Complete Cypress Course

Nine hands-on lessons that take you from zero to shipping E2E tests in CI — every step animated so you can see exactly what to do. 🎬

🎬 9 animated demos 🧠 9 quizzes 📋 Copy-ready code ⏱ ~35 min total

🚀 Start the course

Ready? Let's have fun! 🎉

Pick lesson 1 — your progress is saved automatically.

LESSON 1 · ~4 MIN · SETUP

Install & Setup Cypress

Get Cypress into your project and understand the files it creates — with a live demo of the whole install. 👇

1

Create your project

Make a folder and initialize npm inside it:

bash
mkdir my-cypress-project
cd my-cypress-project
npm init -y
2

Install Cypress

Cypress is installed as a dev dependency — it ships its own Electron browser, no extra setup:

bash
npm install cypress --save-dev
3

Open the launcher

This opens the Cypress app. Choose E2E Testing → pick a browser → Cypress scaffolds your project:

bash
npx cypress open
4

Meet the scaffold

These are the files that appear — you'll use every one of them in this course:

📁 cypress/e2e → your spec files 📁 cypress/fixtures → test data (JSON) 📁 cypress/support → custom commands ⚙️ cypress.config.js → configuration
🎬 Live: installing Cypress & the scaffold appearing DEMO
🧠 QUIZ · LESSON 1

Which command installs Cypress as a dev dependency?

LESSON 2 · ~4 MIN · BASICS

Your First E2E Test

describe → it → cy.visit(). Four steps to your first green checkmark — watch it happen live.

1

Create a spec file

In cypress/e2e/, create an empty file with a .cy.js (or .cy.ts) extension:

📄 first-test.cy.js📦 first-test.cy.ts
2

Write the describe block

describe is your test suite — inside it you can write any number of it() test cases:

first-test.cy.js
describe('My First Test', () => {
  // it blocks and test logic go here
})
3

Add your first test

cy.visit() is the Cypress command that navigates to any URL:

first-test.cy.js
describe('My First Test', () => {
  it('Visits a website', () => {
    cy.visit('https://qa.imcseian.com/')
  })
})
4

Run it!

Save the file, then from your project root:

bash
npx cypress open

Click E2E Testing → choose your browser → click your spec to watch it run.

🎬 Live: writing the test & cy.visit() opening the page DEMO
🧠 QUIZ · LESSON 2

What does cy.visit() do?

LESSON 3 · ~4 MIN · BASICS

Selectors & Actions

Find elements and interact with them — typing, clicking, and finding by text.

1

cy.get() — pick an element

Works with any CSS selector. Pro tip: prefer data-cy attributes — they never change when styles do:

cy.get('#email')cy.get('.btn')cy.get('[data-cy="login"]')
2

Actions

.type() types into inputs, .clear() empties them, .click() clicks buttons & links. cy.contains() finds elements by visible text:

login.cy.js
cy.get('#email').type('qa@tester.io')
cy.get('[data-cy="login"]').click()
cy.contains('Welcome back').should('be.visible')
🎬 Live: type → click → the app reacts DEMO
🧠 QUIZ · LESSON 3

Which selector strategy is most stable for tests?

LESSON 4 · ~3 MIN · BASICS

Assertions with .should()

Prove your app behaves. Chain as many assertions as you like with .and().

1

.should() + .and()

.should() adds an assertion; .and() chains another one on the same element:

first-test.cy.js
cy.get('.title')
  .should('be.visible')
  .and('have.text', 'Welcome')
be.visiblehave.textcontain.text have.length 3have.attr 'href'not.have.text
🎬 Live: assertions hitting the element & passing DEMO
🧠 QUIZ · LESSON 4

Which method chains ANOTHER assertion onto the same element?

LESSON 5 · ~3 MIN · CORE CONCEPT

Auto-Waiting & Retries

The reason Cypress tests are not flaky: commands and assertions retry automatically.

1

How it works

cy.get() and .should() keep retrying for up to 4 seconds (by default) until the element exists / the assertion passes. No cy.wait(5000) hacks — that's an anti-pattern!

2

Custom timeout

Slow-loading element? Extend the timeout per command:

status.cy.js
cy.get('.status', { timeout: 10000 })
  .should('have.text', 'Success')
🎬 Live: the retry loop — fail, retry, retry… pass! DEMO
🧠 QUIZ · LESSON 5

cy.get() finds no element. What happens?

LESSON 6 · ~4 MIN · DATA

Fixtures & Test Data

Keep test data out of your code. Load JSON fixtures and loop through them data-driven style.

1

Create a fixture

Drop a JSON file into cypress/fixtures/:

cypress/fixtures/users.json
{
  "users": [
    { "email": "qa1@tester.io" },
    { "email": "qa2@tester.io" },
    { "email": "admin@corp.io" }
  ]
}
2

Use it in a test

cy.fixture() loads the file; .then() gives you the data. You can also alias it with .as('users') and read it back with cy.get('@users'):

users.cy.js
cy.fixture('users.json').then((users) => {
  users.users.forEach((u) => {
    cy.get('#email').clear().type(u.email)
  })
})
🎬 Live: fixture data flowing into the test DEMO
🧠 QUIZ · LESSON 6

Where do fixture files live?

LESSON 7 · ~4 MIN · DRY CODE

Custom Commands

Repeating the login flow in 12 tests? Wrap it once — use it everywhere as cy.login().

1

Register the command

Add it in cypress/support/commands.js — it's auto-loaded before every spec:

cypress/support/commands.js
Cypress.Commands.add('login', () => {
  cy.get('#email').type('qa@tester.io')
  cy.get('.btn-login').click()
})
2

Use it anywhere

One line replaces the whole flow — and it shows up nicely in the command log:

dashboard.cy.js
cy.login()

Using TypeScript? Declare it: declare namespace Cypress { interface Chainable { login(): Chainable } }

🎬 Live: the command log expanding a custom command DEMO
🧠 QUIZ · LESSON 7

Where do you register custom commands?

LESSON 8 · ~5 MIN · NETWORK

Network Stubbing — cy.intercept()

Catch requests before they hit the real API. Stub responses, test edge cases, go faster.

1

Stub a request

cy.intercept() catches the matching request and serves your fixture instead — the backend never sees it:

dashboard.cy.js
cy.intercept('GET', '/api/users', { fixture: 'users.json' }).as('getUsers')
cy.visit('/dashboard')

cy.wait('@getUsers')
  .its('response.statusCode')
  .should('eq', 200)
2

Why it's powerful

Simulate a 500 error, an empty list, or slow responses — without touching the backend:

{ statusCode: 500 } { body: { users: [] } } { delayMs: 3000 }
🎬 Live: the request being intercepted & mocked DEMO
🧠 QUIZ · LESSON 8

cy.intercept('GET','/api/x',{fixture:'u.json'}) will…

LESSON 9 · ~4 MIN · SHIP IT

Run Cypress in CI/CD

Tests are only useful if they run on every push. Headless mode + GitHub Actions = automated confidence.

1

Headless mode

cypress open is for development. cypress run runs headless — perfect for CI:

bash
npx cypress run
2

GitHub Actions workflow

Create .github/workflows/cypress.yml — the official action starts your app and runs every spec:

.github/workflows/cypress.yml
name: E2E Tests
on: [push]
jobs:
  cypress:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: cypress-io/github-action@v6
        with:
          start: npm start

On failure, Cypress auto-saves screenshots (in cypress/screenshots) and videos (cypress/videos) — upload them as workflow artifacts for debugging.

🎬 Live: the CI pipeline running your tests DEMO
🧠 QUIZ · LESSON 9

Which command runs Cypress headless in CI?

🎓 Course complete — let's have fun! 🎉

You can now write, organize, and ship E2E tests like a pro.

Test Your Knowledge
How did you find this?

Comments

Join the discussion! Sign in with your Google or Blogger account, or comment as Anonymous - no account needed. For quick questions, also reach me on Telegram @cytestch.

Comments