A hands-on Cypress tutorial in JavaScript: from npm install cypress to a suite that runs on Chrome and Firefox in the cloud and in CI. Every demo in this video is a real run of the course code.
What you'll learn
- Install Cypress 14 and run a first spec, headless and in the runner
- Selectors, cy.get versus cy.contains, and the command queue
- Retry-ability: should, callback assertions, and waiting without cy.wait(ms)
- Fixtures, spying and stubbing with cy.intercept, and cy.request
- Custom commands and logging in once with cy.session
- cypress.config.js, setupNodeEvents, cy.task, environment variables and retries
- Component testing versus end-to-end testing
- Running on TestingBot across Chrome and Firefox on Windows 11 with the TestingBot Cypress CLI, and in GitHub Actions
- Debugging: time travel, cy.pause(), .debug(), screenshots, videos and flaky tests
The full course, with code, quick checks and a knowledge check, is free and needs no account: Cypress Tutorial in JavaScript. Free TestingBot Cypress certification (pass the exam and run the course suite green on TestingBot; issued by TestingBot, not by Cypress.io): certification details.
Chapters
- 0:00 Course introduction
- 0:52 Cypress: the command queue and retry-ability
- 1:14 Chapter 1: Install Cypress and Run a First Spec
- 1:48 Chapter 2: Selectors and the Cypress Command Queue
- 2:24 Chapter 3: Cypress Assertions and Waiting Without Sleeps
- 3:03 Chapter 4: Fixtures and Network Stubbing with cy.intercept
- 3:40 Chapter 5: Custom Commands and Logging In Once with cy.session
- 4:21 Chapter 6: Cypress Configuration, Environment Variables and Retries
- 4:50 Chapter 7: Cypress Component Testing vs End-to-End Testing
- 5:14 Chapter 8: Run Cypress on TestingBot and in CI
- 8:15 Chapter 9: Debugging Cypress Tests
- 8:38 Chapter 10: Knowledge check
The presenter is an AI avatar of Jochen Delabie (TestingBot), voiced by a stock AI voice.
Video transcript
Course introduction
Hi, I'm Jochen from TestingBot. This free course teaches Cypress, from an empty folder to a suite that runs in the cloud and in CI. You'll need Node.js, some JavaScript, and a browser. No Cypress experience needed. Chapter by chapter, you build one project. You write your first spec, pick selectors, and learn how the command queue works. You assert with retry-ability instead of sleeps, stub the network with cy.intercept, and log in once with cy.session. Then config, environment variables and retries, and component tests. In chapter eight, the same specs run on TestingBot, on Chrome and Firefox, and from GitHub Actions. When you're done, you can earn the free TestingBot certification. Let's get started.
Cypress: the command queue and retry-ability
Before any code, three ideas explain how Cypress works. Your test runs inside the browser, next to the app. Commands are queued, not executed: Cypress runs them after your test function returns, and each query retries until it finds what it needs. And every test starts clean.
Chapter 1: Install Cypress and Run a First Spec
Chapter one installs Cypress, pinned to version fourteen point two, and lets it scaffold the config and support files. Your first spec visits the example todo app, checks the two default todos, and adds one. You can run it in the interactive runner, or headlessly, the way CI does. Here it is. npx cypress run, headless, the way CI runs it. The todo spec visits the app, checks the two default todos, and adds one. Two passing.
Chapter 2: Selectors and the Cypress Command Queue
Chapter two is about finding elements and the command queue. cy.get finds by selector, cy.contains finds by text, and within narrows the search. Commands don't return elements: they're queued, so you read values with then, aliases, or wrap. Here are the selector tests in the Cypress runner. The selectors spec. Find a todo by its text, tick it, filter to completed, and read values with then. Four passing.
Chapter 3: Cypress Assertions and Waiting Without Sleeps
Chapter three covers assertions and waiting. should and and retry until they pass or time out, so you never need cy.wait with a fixed number. For a slow response, raise the timeout on the query that needs it. Here, a stubbed request takes three seconds, and the test simply waits for the result. Four assertion tests. Chained should and and, an element that is gone, and a callback assertion. The last test waits three seconds for a stubbed response, with no fixed sleep. Four passing.
Chapter 4: Fixtures and Network Stubbing with cy.intercept
Chapter four is about fixtures and the network. cy.intercept can spy on a real request, answer it with a fixture, return an error, or change part of a real response. And cy.request talks to an API without the page. Here are seven network tests, all passing. The network spec. Spy on a real request, stub it with a fixture, return a 404, check what the app sent, edit a real response, and call the API directly. Seven passing.
Chapter 5: Custom Commands and Logging In Once with cy.session
Chapter five adds custom commands. cy.addTodo wraps a few lines you'd repeat in every test. And cy.login uses cy.session, so the login form runs once, and every later test restores the saved cookies instead. Watch the session being created, then reused. The custom command spec, then the secure area spec. The first secure test creates the session: it fills in the login form once. The second test restores the saved session, without the form. Three passing.
Chapter 6: Cypress Configuration, Environment Variables and Retries
Chapter six is about configuration. cypress.config.js sets the base URL, timeouts and retries, and setupNodeEvents registers tasks that run in Node, such as logging. Environment variables come from cypress.env.json, the command line, or CYPRESS variables. And retries rerun a failed test in CI, but never while you're writing it.
Chapter 7: Cypress Component Testing vs End-to-End Testing
Chapter seven compares component tests with end-to-end tests. A component test mounts one React component in the browser, through the dev server Cypress starts for you, so it runs in milliseconds and checks props and events. End-to-end tests check whole user flows. You need both, and the chapter shows when to write which.
Chapter 8: Run Cypress on TestingBot and in CI
Chapter eight runs the same specs on TestingBot. The TestingBot Cypress CLI uploads your project, runs it on the browsers in testingbot.json, and streams the Cypress output back to your terminal. Then it runs from GitHub Actions. Here it is, running for real. First, your credentials. In the TestingBot member area, open Settings, then Security. The API Credentials card has your key and secret, each with a copy button. Keep them out of testingbot.json. Export them as TESTINGBOT_KEY and TESTINGBOT_SECRET; the CLI reads them from the environment. In CI, store them as secrets. npm run cy:testingbot uploads the project to TestingBot. Chrome 157 and Firefox 159 on Windows 11 start side by side, and the CLI streams the Cypress output back. The same six specs run on both browsers, unchanged: the session login, the stubbed network calls, everything. Twenty tests passed on each browser. In the TestingBot dashboard, the build groups both sessions: the same specs on Firefox 159 and Chrome 157, on Windows 11. Both passed. How the build ran shows each session as a bar, one row per parallel slot. The two browsers ran side by side, not one after the other. The summary shows the wall time, fifty-five seconds, and how busy your parallel slots were. More slots means more browsers at once, and a faster build. Open a session to see its environment, here Chrome 157 on Windows 11, and the video of the run: the Cypress runner going through the assertions spec on the todo app. Which browsers run is set in the browsers list in testingbot.json: the platform, the browser name, and the version, up to latest. The docs also cover spec files, the Cypress version, environment variables, geolocation and time zones.
Chapter 9: Debugging Cypress Tests
Chapter nine is about debugging. Time travel in the command log shows the page at every step. cy.pause and debug stop a test so you can look around. Headless runs save screenshots and videos, and on TestingBot every session has its video too. Then a real flaky test, from first failure to fix.
Chapter 10: Knowledge check
That's the course. The last chapter is a knowledge check: ten questions, each with a short explanation. If you'd like something to show an employer, take the free TestingBot certification: pass the exam, and run your suite on TestingBot. Both are linked from the course page.