cypress-testing
FreeNo executable scriptsNot checkedUse 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…
by testland★ 18 GitHub starsAbout 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
- Install Cypress and scaffold the project (
npm install --save-dev cypress,npx cypress open). - Set
baseUrl,specPattern, andretriesincypress.config.ts. - Add
@testing-library/cypressso specs select by role / label, not by CSS class. - Author each flow as a
describe/itblock; lean on auto-waiting assertions instead ofcy.wait(ms). - Extract repeated auth into a
cy.session-backed custom command called frombeforeEach. - Stub or wait on network calls with
cy.intercept+cy.wait('@alias')instead of fixed sleeps. - Seed data with
cy.task, load canned responses with fixtures, freeze time withcy.clock. - Drive a login on another origin (SSO, auth subdomain) inside
cy.origin. - Run headless in CI (
npx cypress run); debug failures by replaying commands in the time-travel GUI. - 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
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
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
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
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic