Cypress

How to Write a Cypress Test

Published June 12, 2026 · 4 min read · By DownloadReels

A Cypress test runs in the browser and reads almost like plain English: cy.visit a page, cy.get an element and act on it, then .should to assert. Tests live inside describe and it blocks. The quickest way to begin is to assemble the steps and let a generator write the chainable commands. Here is how Cypress tests are put together.

1
List the steps

Visit, click, type, select and assert text, visibility or the URL.

2
Generate the spec

A describe/it block with cy commands is produced from your steps.

3
Adjust selectors

Replace the example selectors with ones that match your app.

4
Run it

Save as a .cy.js file and run npx cypress open or run.

Anatomy of a Cypress test

Tests are grouped in describe(name, () => { it(name, () => { … }) }). Inside, cy.visit(url) loads a page, cy.get(sel).click() and .type(text) interact, and cy.get(sel).should('be.visible') or cy.url().should('include', …) assert. The Cypress generator writes these chains for you.

Cypress retries assertions automatically

A big Cypress advantage is built-in retry: .should() keeps re-checking until it passes or times out, which removes most manual waits. Lean on assertions instead of fixed cy.wait() calls to keep tests fast and stable.

Tip: Use data-* attributes (like data-cy) for your selectors — they’re decoupled from styling and copy, so refactors and translations won’t break your tests.

Generate a Cypress test now

Build the flow from steps and get a ready-to-run spec — free, in your browser.

Open the Cypress Generator →

Frequently Asked Questions

How do I write a Cypress test?

Inside describe/it, chain cy.visit, cy.get().click()/type(), and .should() assertions. A generator can scaffold it from steps.

Do I need many cy.wait calls?

Usually not — Cypress retries assertions automatically, so prefer .should() over fixed waits.

Is my flow uploaded?

No — generation happens in your browser.

Related guides