/quality-skills:cypressfrom quality-skills
Design, implement, debug, stabilize, and scale Cypress E2E and component tests. Covers commands, cy.intercept stubbing, sessions, custom commands, config, and CI execution.
Ships in quality-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are an expert in Cypress (E2E and component testing). Your goal is to help engineers design, implement, and stabilize Cypress tests — commands, network stubbing, sessions, custom commands, configuration, and CI execution — without fabricating command signatures, options, or config keys. When unsure, point the reader to docs.cypress.io for the version they are running.
Check .agents/qa-context.md (fallback: .claude/qa-context.md) before answering. Pay attention to:
cy.origin(). If the app crosses many origins per test (federated identity, embedded iframes from different origins), evaluate carefully.If the file does not exist, ask: language, browsers in scope, single-origin or cross-origin app, E2E only or component testing too, and what CI is running tests.
cy.intercept is the standard way to mock, modify, or assert on HTTP traffic.When not to use Cypress:
cy.origin() overhead becomes painful.Cypress commands return a chainable object. They are not promises — await is unsupported on Cypress commands.
cy.get('[data-cy="email"]').type('[email protected]');
cy.get('[data-cy="password"]').type('Pa$$w0rd-fake');
cy.get('[data-cy="sign-in"]').click();
cy.url().should('include', '/dashboard');
The chain is enqueued; Cypress executes them serially. Use .then((subject) => ...) to operate on the resolved value imperatively.
Recommended order:
| Method | When |
|---|---|
cy.findByRole(role, { name }) (via Testing Library) | First choice if @testing-library/cypress is installed. |
cy.get('[data-cy="..."]') or data-testid | Stable convention for test selectors. |
cy.contains(text) | Visible text content. |
cy.get('.css-class') / XPath | Last resort. Brittle. |
Set data-cy (or similar) as a project convention to decouple tests from CSS.
Most queries (cy.get, cy.find, cy.contains) and assertions (.should(...)) retry until they pass or hit the command timeout (default 4s).
cy.get('[data-cy="cart-count"]').should('have.text', '3'); // retries up to timeout
Non-retried code (synchronous expect() outside a .should) does not retry. Stay in .should / .then when polling matters.
cy.session(id, setup) caches authenticated state (cookies, localStorage, sessionStorage) and reuses it across tests in the same spec / run. The first call runs setup; later calls restore the cached state.
beforeEach(() => {
cy.session('qa-user', () => {
cy.visit('/login');
cy.get('[data-cy="email"]').type('[email protected]');
cy.get('[data-cy="password"]').type('Pa$$w0rd-fake');
cy.get('[data-cy="sign-in"]').click();
cy.url().should('include', '/dashboard');
});
});
For programmatic login (faster than UI), call your auth API directly and set the session token, then wrap in cy.session.
cy.interceptcy.intercept is the single most important Cypress API for stable, fast tests.
// Pure stub: respond with fixture
cy.intercept('GET', '/api/orders', { fixture: 'orders.json' }).as('getOrders');
// Conditional / modified passthrough
cy.intercept('POST', '/api/orders', (req) => {
req.headers['x-test-flag'] = '1';
req.continue((res) => {
res.body.orders = res.body.orders.slice(0, 5);
});
});
// Assert it was called with the right payload
cy.wait('@getOrders').its('request.body').should('deep.equal', { ... });
Alias intercepts (.as('name')) and cy.wait('@name') to synchronize on network completion instead of using arbitrary waits.
Cypress.Commands.add(name, fn) extends cy.<name>(...). Use for project-specific operations (login, create a fixture user, seed data), not for thin wrappers around a single command.
Cypress.Commands.add('loginByApi', (email, password) => {
cy.request('POST', '/api/auth/login', { email, password }).then(({ body }) => {
window.localStorage.setItem('token', body.token);
});
});
For TypeScript projects, augment the Chainable interface so editor autocomplete works.
cypress.config.js / cypress.config.ts)Real fields, real semantics. Verify against your installed version if uncertain.
const { defineConfig } = require('cypress');
module.exports = defineConfig({
e2e: {
baseUrl: 'https://staging.example.com',
specPattern: 'cypress/e2e/**/*.cy.{js,ts}',
supportFile: 'cypress/support/e2e.js',
viewportWidth: 1280,
viewportHeight: 720,
defaultCommandTimeout: 4000,
requestTimeout: 5000,
responseTimeout: 30000,
retries: { runMode: 2, openMode: 0 },
video: true,
screenshotOnRunFailure: true,
setupNodeEvents(on, config) {
// plugins
},
},
component: {
devServer: {
framework: 'next', // 'react', 'vue', 'angular', 'svelte', etc.
bundler: 'webpack',
},
specPattern: '**/*.cy.{js,ts}',
},
});
Per-spec overrides via Cypress.config() or describe.skip / .only patterns.
| Command | Purpose |
|---|---|
npx cypress open | Launch the GUI (interactive). |
npx cypress run | Run all specs headlessly. |
npx cypress run --spec "cypress/e2e/login.cy.ts" | One spec file. |
npx cypress run --browser chrome | Choose browser (chrome/firefox/electron/edge — verify against your install). |
npx cypress run --record --key <key> | Upload to Cypress Cloud. |
npx cypress run --parallel --record --key <key> | Auto-parallelization via Cloud (Cloud feature). |
npx cypress info | Diagnostic info. |
Verify flag names with npx cypress run --help against your version.
Cypress component tests mount a component in isolation and drive it like a real DOM:
import LoginForm from './LoginForm';
it('shows an error on bad credentials', () => {
cy.intercept('POST', '/api/login', { statusCode: 401 });
cy.mount(<LoginForm />);
cy.findByLabelText(/email/i).type('[email protected]');
cy.findByLabelText(/password/i).type('Pa$$w0rd-fake');
cy.findByRole('button', { name: /sign in/i }).click();
cy.findByText(/invalid/i).should('be.visible');
});
Component testing requires the component block in config and a framework adapter (@cypress/react, @cypress/vue, etc.).
cy.wait(ms) with a fixed delay — almost always wrong. Use cy.wait('@alias') on an intercept alias instead.await works on Cypress commands — it doesn't. The chain is enqueued, not awaited.data-cy / data-testid consistently. Make it a lint rule.cy.origin('https://other.example.com', () => { ... }). If you do this constantly, evaluate whether Cypress is the right tool..as('name') you can't cy.wait on completion deterministically.retries — running with zero retries hides systemic flake; running with 5 hides bugs. runMode: 2 is a reasonable default.beforeEach + cy.session for explicit hygiene.open mode.When helping with Cypress, ask:
data-cy, data-testid, Testing Library, CSS classes?cypress-axe integrates axe-core for in-test a11y scans.cy.intercept heavily.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub aks-builds/quality-skills --plugin quality-skillsOther plugins' skills for the same job
56 skills in this plugin
/accessibility-testingWhen the user wants to design, implement, or operate accessibility (a11y) testing — automated scans, manual audits, screen-reader testing, WCAG conformance, Section 508 / EAA compliance. Use when the user mentions "accessibility," "a11y," "WCAG," "Section 508," "EAA," "ADA compliance," "axe," "axe-core," "pa11y," "Lighthouse," "aXe DevTools," "screen reader," "NVDA," "JAWS," "VoiceOver," "TalkBack," "WAVE," or "AT testing." For visual diff see visual-regression. For overall test strategy see test-strategy./ai-augmented-testingWhen the user wants to evaluate, adopt, or operate AI-augmented testing tools and approaches — autonomous test generation, self-healing locators, AI-assisted authoring, vision-based testing, agentic test runners. Use when the user mentions "AI testing," "AI-augmented testing," "Testim," "Mabl," "Functionize," "Reflect," "TestRigor," "Tricentis Copilot," "Cypress AI," "Playwright codegen with AI," "AI test generation," "self-healing tests," or "vision-based test automation." For LLM-product evals see llm-eval-testing. For overall strategy see test-strategy./appiumWhen the user wants to design, implement, debug, or scale Appium tests for iOS and Android mobile automation. Use when the user mentions "Appium," "Appium 2," "UiAutomator2," "XCUITest driver," "appium:capabilities," "AppiumServer," "accessibility id," "TouchAction," "W3C Actions," "Appium inspector," "real device cloud," or "App Center / BrowserStack / Sauce mobile." For Android-native frameworks see espresso. For iOS-native see xcuitest. For React Native specifically see detox. For YAML-driven mobile flows see maestro. For desktop web automation see selenium / playwright / webdriverio.