Skip to content
BENIBIX Learn

Cypress

Development🧪 Testing & QualityTest Frameworks

Also known as Cypress.io, Cypress Testing, Cypress E2E

A JavaScript tool that tests web apps in a real browser. You see each step.

Think of it like

Think of it like a robot shopper you can watch. It walks through your store while you see each step.

Example

Jack's Cypress test opens the shop, adds a mug and checks the cart shows 1. It runs on every pull request.

Why it matters

You can watch each step of a failing test, which makes it fast to fix.

Definition

Cypress is a JavaScript tool for testing web apps in a real browser. It runs inside the browser, beside the app, so it sees each step as it happens. It does end-to-end tests and tests for single components. A runner window shows every step, so you can go back and see what failed. It works with Chrome-family browsers and Firefox.

Example code

javascript
it("adds a mug to the cart", () => {
  cy.visit("/shop");
  cy.contains("Add to cart").click();
  cy.get("[data-cy=cart-count]").should("have.text", "1");
});
Visit the page, click the button, check the cart count.
Cypress drives a real browser for end-to-end tests.

Common mistake

Finding elements by their look, like a CSS class. Use a test-only label, so a redesign does not break tests.

Key takeaways

  1. 1
    Real browser. Runs beside the app.
  2. 2
    Watch it run. Step back through each action.
  3. 3
    Stable labels. Find elements by test labels.

Compare