Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

cypress-testing

FreeNo executable scriptsNot checked

Use for any question or task about Cypress tests, including quick how-to questions and one pasted test to fix: stubbing API calls with cy.intercept, replacing…

testlandby testland★ 18 GitHub stars

About this skill

cypress-testing

Overview

Per cy-overview:

"Cypress is described as 'a next generation front end testing tool built for the modern web.'"

Differentiators (cy-overview):

  • Time Travel Debugging: "Cypress takes snapshots as your tests run. Hover over commands in the Command Log to see exactly what happened at each step."
  • Automatic Waiting: "Never add waits or sleeps to your tests. Cypress automatically waits for commands and assertions before moving on."
  • Reliability: "The testing approach avoids Selenium/WebDriver architecture, resulting in fast, consistent and reliable tests that are flake-free."

When to use

  • The team has invested in Cypress; a migration is unlikely.
  • The test author values the time-travel debugger / GUI experience.
  • Component testing is needed (Cypress supports React / Angular / Vue / Svelte component testing).
  • Single-browser focus is acceptable (Chromium-first; Firefox / Edge supported but secondary).

For cross-browser including WebKit, see playwright-testing.

How to use

  1. Install Cypress and scaffold the project (npm install --save-dev cypress, npx cypress open).
  2. Set baseUrl, specPattern, and retries in cypress.config.ts.
  3. Add @testing-library/cypress so specs select by role / label, not by CSS class.
  4. Author each flow as a describe / it block; lean on auto-waiting assertions instead of cy.wait(ms).
  5. Extract repeated auth into a cy.session-backed custom command called from beforeEach.
  6. Stub or wait on network calls with cy.intercept + cy.wait('@alias') instead of fixed sleeps.
  7. Seed data with cy.task, load canned responses with fixtures, freeze time with cy.clock.
  8. Drive a login on another origin (SSO, auth subdomain) inside cy.origin.
  9. Run headless in CI (npx cypress run); debug failures by replaying commands in the time-travel GUI.
  10. For scale, record + parallelize via Cypress Cloud and upload screenshot artifacts on failure (see references/ci-and-cloud.md).

Step 1 - Install

npm install --save-dev cypress
npx cypress open   # first run scaffolds the project

The interactive setup creates cypress.config.ts + cypress/ directory.

Per the changelog, Cypress 16.0.0 (Sep 1, 2026) "requires Node.js 22.x, 24.x, or >=26.x". Upgrading a 15.x suite? See "Upgrading to Cypress 16" below before bumping the version.

Step 2 - Configure

// cypress.config.ts
import { defineConfig } from 'cypress';

export default defineConfig({
  e2e: {
    baseUrl: 'http://localhost:3000',
    specPattern: 'cypress/e2e/**/*.cy.{ts,tsx}',
    video: true,
    screenshotOnRunFailure: true,
    retries: { runMode: 2, openMode: 0 },
  },
  component: {
    devServer: {
      framework: 'react',
      bundler: 'vite',
    },
  },
});

Step 3 - Author E2E tests

// cypress/e2e/checkout.cy.ts
describe('Checkout flow', () => {
  beforeEach(() => {
    cy.visit('/login');
    cy.get('[data-testid="email"]').type('[email protected]');
    cy.env(['USER_PASSWORD']).then(({ USER_PASSWORD }) => {
      cy.get('[data-testid="password"]').type(USER_PASSWORD, { log: false });
    });
    cy.get('[data-testid="signin-btn"]').click();
    cy.contains('Welcome').should('be.visible');
  });

  it('completes checkout end-to-end', () => {
    cy.visit('/products/BOOK-001');
    cy.contains('button', /add to cart/i).click();
    cy.get('[data-testid="cart-count"]').should('have.text', '1');

    cy.visit('/checkout');
    cy.env(['TEST_CARD_NUMBER']).then(({ TEST_CARD_NUMBER }) => {
      cy.get('[name="card"]').type(TEST_CARD_NUMBER, { log: false });
    });
    cy.contains('button', /place order/i).click();
    cy.contains('Order confirmed', { timeout: 10000 }).should('be.visible');
  });
});

Per cy-overview, assertions auto-wait - no cy.wait(2000) needed.

Never type a password or card number as a literal. Per cy-env, cy.env() (Cypress 15.10+) yields the requested keys, and per cy-env-guide Cypress strips the CYPRESS_ prefix, so CI sets CYPRESS_USER_PASSWORD from its secret store. { log: false } keeps the value out of the Command Log.

Step 4 - Use cypress-testing-library

For accessibility-first selectors:

npm install --save-dev @testing-library/cypress
// cypress/support/commands.ts
import '@testing-library/cypress/add-commands';

// Now in tests:
cy.findByRole('button', { name: /sign in/i }).click();
cy.findByLabelText('Email').type('[email protected]');

findByRole (from cypress-testing-library) is the Cypress equivalent of Playwright's getByRole - preferred for

Full SKILL.md on GitHub

Install cypress-testing in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

.tessl-plugin/plugin.jsonevals/config-retries-and-artifacts/criteria.jsonevals/config-retries-and-artifacts/task.mdevals/csv-import-export-spec-cannot-run/criteria.jsonevals/csv-import-export-spec-cannot-run/task.mdevals/notification-checks-fail-once-then-stay-failed/criteria.jsonevals/notification-checks-fail-once-then-stay-failed/task.mdevals/order-dependent-orders-spec/criteria.jsonevals/order-dependent-orders-spec/task.mdevals/price-panel-states-unreachable-from-the-app/criteria.jsonevals/price-panel-states-unreachable-from-the-app/task.mdevals/quote-totals-compare-against-undefined/criteria.jsonevals/quote-totals-compare-against-undefined/task.mdevals/repeated-login-and-sleeps/criteria.jsonevals/repeated-login-and-sleeps/task.mdevals/search-stubs-hid-a-backend-rename/criteria.jsonevals/search-stubs-hid-a-backend-rename/task.mdevals/sso-redirect-killed-the-checkout-spec/criteria.jsonevals/sso-redirect-killed-the-checkout-spec/task.mdevals/trial-banner-tests-need-two-weeks/criteria.jsonevals/trial-banner-tests-need-two-weeks/task.mdreferences/ci-and-cloud.md

FAQ

What does the cypress-testing skill do?

Use for any question or task about Cypress tests, including quick how-to questions and one pasted test to fix: stubbing API calls with cy.intercept, replacing cy.wait sleeps with assertions, tests that pass locally but fail in CI, fixtures and cy.task, cy.clock, cy.origin and cy.session logins, cypress.config.ts, the Cypress 16 upgrade and Cloud parallel runs.

How do I install the cypress-testing skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the cypress-testing skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare cypress-testing with