Skip to main content
skill CX Codex

cypress-skill — Claude Code skill: E2E testing with Cypress

Generates production-grade E2E and component tests in JavaScript or TypeScript. Runs tests locally or on TestMu AI cloud, understands Cypress commands, and writes tests with proper selectors and network interception.

MIT 264 installs ★ 393 updated 2026-10-13

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add LambdaTest/agent-skills --skill cypress-skill -a claude-code
Open on GitHub

What cypress-skill does

This skill embeds Cypress expertise and turns a test request into working code. It knows when to use local execution (npx cypress open) and when to run on LambdaTest cloud for cross-browser testing. Inside: full patterns from basic command chains to cy.intercept() for API mocking, cy.session() for auth, and Page Object design.

No arbitrary wait timers — only explicit waits via network interception. Selector priority: data-cy first, then data-testid, text, ID. No async/await mixed with Cypress commands; everything chains through .then(). The skill spots anti-patterns: assigning cy.get() to a variable, testing third-party sites, bloated beforeEach blocks.

Cloud mode needs LT_USERNAME and LT_ACCESS_KEY in environment variables. The skill configures lambdatest-config.json, handles browser matrix and parallelism. Component tests (React, Vue, Angular) get a separate path in cypress/component/. Everything comes from one Skills registry; the agent picks E2E or component based on keywords in your prompt.

What it helps with

  • Write E2E tests for a login flow with error validation
  • Intercept and stub an API response in a test
  • Set up component tests for a React component with variants
  • Run tests in parallel across browsers on the cloud
  • Add a custom command for session-based authentication

Example prompts for the agent

  • Write an E2E test for the login page, covering successful login and wrong password error
  • Create a test that intercepts POST /api/login and returns a fake JWT token
  • Set up a component test for a React Button with primary and disabled states

How to install cypress-skill

1Skills CLI (Vercel)

npx skills add LambdaTest/agent-skills --skill cypress-skill -a claude-code

2Manually: put the files in place

~/.claude/skills/cypress-skill/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/cypress-skill/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about cypress-skill

How do I install cypress-skill?

Run npx skills add LambdaTest/agent-skills --skill cypress-skill -a claude-code, then open ~/.claude/skills/cypress-skill/SKILL.md. For other platforms, use codex, cursor, or gemini-cli instead of claude-code.

What does cypress-skill do?

It generates complete Cypress tests: E2E, component, and API. It knows how to write command chains without async/await, how to intercept and mock API responses, and how to use data-cy selectors. Tests run locally or on TestMu cloud.

When should I use cloud execution instead of local?

Mention "cloud", "cross-browser", "TestMu", or "LambdaTest" and the skill routes to cloud with parallel execution across browsers. You need LT_USERNAME and LT_ACCESS_KEY environment variables. By default, it suggests local execution.

Source text

SKILL.md · MIT
---
name: cypress-skill
description: >
  Generates production-grade Cypress E2E and component tests in JavaScript
  or TypeScript. Supports local execution and TestMu AI cloud. Use when
  the user asks to write Cypress tests, set up Cypress, test with cy commands,
  or mentions "Cypress", "cy.visit", "cy.get", "cy.intercept". Triggers on:
  "Cypress", "cy.", "component test", "E2E test", "TestMu", "LambdaTest".
languages:
  - JavaScript
  - TypeScript
category: e2e-testing
license: MIT
metadata:
  author: TestMu AI
  version: "1.0"
---

# Cypress Automation Skill

You are a senior QA automation architect specializing in Cypress.

## Step 1 — Execution Target

```
User says "test" / "automate"
│
├─ Mentions "cloud", "TestMu", "LambdaTest", "cross-browser"?
│  └─ TestMu AI cloud via cypress-cli plugin
│
├─ Mentions "locally", "open", "headed"?
│  └─ Local: npx cypress open
│
└─ Ambiguous? → Default local, mention cloud option
```

## Step 2 — Test Type

| Signal | Type | Config |
|--------|------|--------|
| "E2E", "end-to-end", page URL | E2E test | `cypress/e2e/` |
| "component", "React", "Vue" | Component test | `cypress/component/` |
| "API test", "cy.request" | API test via Cypress | `cypress/e2e/api/` |

## Core Patterns

### Command Chaining — CRITICAL

```javascript
// ✅ Cypress chains — no await, no async
cy.visit('/login');
cy.get('#username').type('[email protected]');
cy.get('#password').type('password123');
cy.get('button[type="submit"]').click();
cy.url().should('include', '/dashboard');

// ❌ NEVER use async/await with cy commands
// ❌ NEVER assign cy.get() to a variable for later use
```

### Selector Priority

```
1. cy.get('[data-cy="submit"]')     ← Best practice
2. cy.get('[data-testid="submit"]') ← Also good
3. cy.contains('Submit')            ← Text-based
4. cy.get('#submit-btn')            ← ID
5. cy.get('.btn-primary')           ← Class (fragile)
```

### Anti-Patterns

| Bad | Good | Why |
|-----|------|-----|
| `cy.wait(5000)` | `cy.intercept()` + `cy.wait('@alias')` | Arbitrary waits |
| `const el = cy.get()` | Chain directly | Cypress is async |
| `async/await` with cy | Chain `.then()` if needed | Different async model |
| Testing 3rd party sites | Stub/mock instead | Flaky, slow |
| Single `beforeEach` with everything | Multiple focused specs | Better isolation |

### Basic Test Structure

```javascript
describe('Login', () => {
  beforeEach(() => {
    cy.visit('/login');
  });

  it('should login with valid credentials', () => {
    cy.get('[data-cy="username"]').type('[email protected]');
    cy.get('[data-cy="password"]').type('password123');
    cy.get('[data-cy="submit"]').click();
    cy.url().should('include', '/dashboard');
    cy.get('[data-cy="welcome"]').should('contain', 'Welcome');
  });

  it('should show error for invalid credentials', () => {
    cy.get('[data-cy="username"]').type('[email protected]');
    cy.get('[data-cy="password"]').type('wrong');
    cy.get('[data-cy="submit"]').click();
    cy.get('[data-cy="error"]').should('be.visible');
  });
});
```

### Network Interception

```javascript
// Stub API response
cy.intercept('POST', '/api/login', {
  statusCode: 200,
  body: { token: 'fake-jwt', user: { name: 'Test User' } },
}).as('loginRequest');

cy.get('[data-cy="submit"]').click();
cy.wait('@loginRequest').its('request.body').should('deep.include', {
  email: '[email protected]',
});

// Wait for real API
cy.intercept('GET', '/api/dashboard').as('dashboardLoad');
cy.visit('/dashboard');
cy.wait('@dashboardLoad');
```

### Custom Commands

```javascript
// cypress/support/commands.js
Cypress.Commands.add('login', (email, password) => {
  cy.session([email, password], () => {
    cy.visit('/login');
    cy.get('[data-cy="username"]').type(email);
    cy.get('[data-cy="password"]').type(password);
    cy.get('[data-cy="submit"]').click();
    cy.url().should('include', '/dashboard');
  });
});

// Usage in tests
cy.login('[email protected]', 'password123');
```

### TestMu AI Cloud

```javascript
// cypress.config.js
module.exports = {
  e2e: {
    setupNodeEvents(on, config) {
      // LambdaTest plugin
    },
  },
};

// lambdatest-config.json
{
  "lambdatest_auth": {
    "username": "${LT_USERNAME}",
    "access_key": "${LT_ACCESS_KEY}"
  },
  "browsers": [
    { "browser": "Chrome", "platform": "Windows 11", "versions": ["latest"] },
    { "browser": "Firefox", "platform": "macOS Sequoia", "versions": ["latest"] }
  ],
  "run_settings": {
    "build_name": "Cypress Build",
    "parallels": 5,
    "specs": "cypress/e2e/**/*.cy.js"
  }
}
```

**Run on cloud:**
```bash
npx lambdatest-cypress run
```

## Validation Workflow

1. **No arbitrary waits**: Zero `cy.wait(number)` — use intercepts
2. **Selectors**: Prefer `data-cy` attributes
3. **No async/await**: Pure Cypress chaining
4. **Assertions**: Use `.should()` chains, not manual checks
5. **Isolation**: Each test independent, use `cy.session()` for auth

## Quick Reference

| Task | Command |
|------|---------|
| Open interactive | `npx cypress open` |
| Run headless | `npx cypress run` |
| Run specific spec | `npx cypress run --spec "cypress/e2e/login.cy.js"` |
| Run in browser | `npx cypress run --browser chrome` |
| Component tests | `npx cypress run --component` |
| Environment vars | `CYPRESS_BASE_URL=http://localhost:3000 npx cypress run` |
| Fixtures | `cy.fixture('users.json').then(data => ...)` |
| File upload | `cy.get('input[type="file"]').selectFile('file.pdf')` |
| Viewport | `cy.viewport('iphone-x')` or `cy.viewport(1280, 720)` |
| Screenshot | `cy.screenshot('login-page')` |

## Reference Files

| File | When to Read |
|------|-------------|
| `reference/cloud-integration.md` | LambdaTest Cypress CLI, parallel, config |
| `reference/component-testing.md` | React/Vue/Angular component tests |
| `reference/custom-commands.md` | Advanced commands, overwrite, TypeScript |
| `reference/debugging-flaky.md` | Retry-ability, detached DOM, race conditions |

## Advanced Playbook

For production-grade patterns, see `reference/playbook.md`:

| Section | What's Inside |
|---------|--------------|
| §1 Production Config | Multi-env configs, setupNodeEvents |
| §2 Auth with cy.session() | UI login, API login, validation |
| §3 Page Object Pattern | Fluent page classes, barrel exports |
| §4 Network Interception | Mock, modify, delay, wait for API |
| §5 Component Testing | React/Vue mount, stubs, variants |
| §6 Custom Commands | TypeScript declarations, drag-drop |
| §7 DB Reset & Seeding | API reset, Cypress tasks, Prisma |
| §8 Time Control | cy.clock(), cy.tick() |
| §9 File Operations | Upload, drag-drop, download verify |
| §10 iframe & Shadow DOM | Content access patterns |
| §11 Accessibility | cypress-axe, WCAG audits |
| §12 Visual Regression | Percy, cypress-image-snapshot |
| §13 CI/CD | GitHub Actions matrix + Cypress Cloud parallel |
| §14 Debugging Table | 11 common problems with fixes |
| §15 Best Practices | 15-item production checklist |

© TestMu AI · MIT · LambdaTest/agent-skills

Similar skills

All skills for Testing and QA →

From the same set47

The whole set →
junit-5-skill Generates production-grade JUnit 5 unit tests for Java with assertions, parameterized tests, Mockito mocks, and nested test groups. Use it to quickly cover your Java code with tests. CX Codex +1 289installs phpunit-skill This skill generates PHPUnit tests for PHP code, including assertions, data providers, mocks, and test doubles. Use it when you need tests shaped around a class or service. CX Codex +1 287installs cucumber-skill Creates Gherkin feature files and matching step definitions. Use it to turn application behavior into Cucumber BDD scenarios. CX Codex +1 283installs webdriverio-skill Generates WebdriverIO end-to-end tests in JavaScript or TypeScript for local runs and TestMu AI cloud. CX Codex +1 265installs robot-framework-skill robot-framework-skill turns a described scenario into a .robot test in keyword-driven syntax, with SeleniumLibrary for browser flows and RequestsLibrary for API checks. CX Codex +1 253installs detox-skill Generates Detox E2E tests for React Native projects in JavaScript and TypeScript. Sets up tests for local emulators and TestMu AI cloud runs. CX Codex +1 252installs hyperexecute-skill This skill prepares and runs HyperExecute test jobs, checks YAML locally, connects CI, and helps investigate failed cloud runs. CX Codex +1 250installs xcuitest-skill Generates XCUITest UI tests for iOS and iPadOS apps. Detects whether to use local Xcode simulators or TestMu AI cloud devices, then builds test code accordingly. CX Codex +1 248installs

Project sponsors

Companies that keep this analytics open