Cypress Automation Skill
When to Use
Use this skill when you need 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"....
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
// ✅ Cypress chains — no await, no async
cy.visit('/login');
cy.get('#username').type('user@test.com');
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
describe('Login', () => {
beforeEach(() => {
cy.visit('/login');
});
it('should login with valid credentials', () => {
cy.get('[data-cy="username"]').type('user@test.com');
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('wrong@test.com');
cy.get('[data-cy="password"]').type('wrong');
cy.get('[data-cy="submit"]').click();
cy.get('[data-cy="error"]').should('be.visible');
});
});
Network Interception
// 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: 'user@test.com',
});
// Wait for real API
cy.intercept('GET', '/api/dashboard').as('dashboardLoad');
cy.visit('/dashboard');
cy.wait('@dashboardLoad');
Custom Commands
// 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('user@test.com', 'password123');
TestMu AI Cloud
// 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:
npx lambdatest-cypress run
Validation Workflow
- No arbitrary waits: Zero
cy.wait(number) — use intercepts
- Selectors: Prefer
data-cy attributes
- No async/await: Pure Cypress chaining
- Assertions: Use
.should() chains, not manual checks
- 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 |
Limitations
- Use this skill only when the task clearly matches its upstream source and local project context.
- Verify commands, generated code, dependencies, credentials, and external service behavior before applying changes.
- Do not treat examples as a substitute for environment-specific tests, security review, or user approval for destructive or costly actions.
1---
2name: cypress-skill
3description: "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\"."
4risk: critical
5source: https://github.com/LambdaTest/agent-skills/tree/main/cypress-skill
6source_repo: LambdaTest/agent-skills
7source_type: community
8date_added: 2026-07-01
9license: MIT
10license_source: https://github.com/LambdaTest/agent-skills/blob/main/LICENSE
11metadata:
12 source: https://skillmd.com/skills/lambdatest/cypress-skill
13---
14
15# Cypress Automation Skill
16## When to Use
17
18Use this skill when you need 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"....
19
20
21You are a senior QA automation architect specializing in Cypress.
22
23## Step 1 — Execution Target
24
25```
26User says "test" / "automate"
27│
28├─ Mentions "cloud", "TestMu", "LambdaTest", "cross-browser"?
29│ └─ TestMu AI cloud via cypress-cli plugin
30│
31├─ Mentions "locally", "open", "headed"?
32│ └─ Local: npx cypress open
33│
34└─ Ambiguous? → Default local, mention cloud option
35```
36
37## Step 2 — Test Type
38
39| Signal | Type | Config |
40|--------|------|--------|
41| "E2E", "end-to-end", page URL | E2E test | `cypress/e2e/` |
42| "component", "React", "Vue" | Component test | `cypress/component/` |
43| "API test", "cy.request" | API test via Cypress | `cypress/e2e/api/` |
44
45## Core Patterns
46
47### Command Chaining — CRITICAL
48
49```javascript
50// ✅ Cypress chains — no await, no async
51cy.visit('/login');
52cy.get('#username').type('user@test.com');
53cy.get('#password').type('password123');
54cy.get('button[type="submit"]').click();
55cy.url().should('include', '/dashboard');
56
57// ❌ NEVER use async/await with cy commands
58// ❌ NEVER assign cy.get() to a variable for later use
59```
60
61### Selector Priority
62
63```
641. cy.get('[data-cy="submit"]') ← Best practice
652. cy.get('[data-testid="submit"]') ← Also good
663. cy.contains('Submit') ← Text-based
674. cy.get('#submit-btn') ← ID
685. cy.get('.btn-primary') ← Class (fragile)
69```
70
71### Anti-Patterns
72
73| Bad | Good | Why |
74|-----|------|-----|
75| `cy.wait(5000)` | `cy.intercept()` + `cy.wait('@alias')` | Arbitrary waits |
76| `const el = cy.get()` | Chain directly | Cypress is async |
77| `async/await` with cy | Chain `.then()` if needed | Different async model |
78| Testing 3rd party sites | Stub/mock instead | Flaky, slow |
79| Single `beforeEach` with everything | Multiple focused specs | Better isolation |
80
81### Basic Test Structure
82
83```javascript
84describe('Login', () => {
85 beforeEach(() => {
86 cy.visit('/login');
87 });
88
89 it('should login with valid credentials', () => {
90 cy.get('[data-cy="username"]').type('user@test.com');
91 cy.get('[data-cy="password"]').type('password123');
92 cy.get('[data-cy="submit"]').click();
93 cy.url().should('include', '/dashboard');
94 cy.get('[data-cy="welcome"]').should('contain', 'Welcome');
95 });
96
97 it('should show error for invalid credentials', () => {
98 cy.get('[data-cy="username"]').type('wrong@test.com');
99 cy.get('[data-cy="password"]').type('wrong');
100 cy.get('[data-cy="submit"]').click();
101 cy.get('[data-cy="error"]').should('be.visible');
102 });
103});
104```
105
106### Network Interception
107
108```javascript
109// Stub API response
110cy.intercept('POST', '/api/login', {
111 statusCode: 200,
112 body: { token: 'fake-jwt', user: { name: 'Test User' } },
113}).as('loginRequest');
114
115cy.get('[data-cy="submit"]').click();
116cy.wait('@loginRequest').its('request.body').should('deep.include', {
117 email: 'user@test.com',
118});
119
120// Wait for real API
121cy.intercept('GET', '/api/dashboard').as('dashboardLoad');
122cy.visit('/dashboard');
123cy.wait('@dashboardLoad');
124```
125
126### Custom Commands
127
128```javascript
129// cypress/support/commands.js
130Cypress.Commands.add('login', (email, password) => {
131 cy.session([email, password], () => {
132 cy.visit('/login');
133 cy.get('[data-cy="username"]').type(email);
134 cy.get('[data-cy="password"]').type(password);
135 cy.get('[data-cy="submit"]').click();
136 cy.url().should('include', '/dashboard');
137 });
138});
139
140// Usage in tests
141cy.login('user@test.com', 'password123');
142```
143
144### TestMu AI Cloud
145
146```javascript
147// cypress.config.js
148module.exports = {
149 e2e: {
150 setupNodeEvents(on, config) {
151 // LambdaTest plugin
152 },
153 },
154};
155
156// lambdatest-config.json
157{
158 "lambdatest_auth": {
159 "username": "${LT_USERNAME}",
160 "access_key": "${LT_ACCESS_KEY}"
161 },
162 "browsers": [
163 { "browser": "Chrome", "platform": "Windows 11", "versions": ["latest"] },
164 { "browser": "Firefox", "platform": "macOS Sequoia", "versions": ["latest"] }
165 ],
166 "run_settings": {
167 "build_name": "Cypress Build",
168 "parallels": 5,
169 "specs": "cypress/e2e/**/*.cy.js"
170 }
171}
172```
173
174**Run on cloud:**
175```bash
176npx lambdatest-cypress run
177```
178
179## Validation Workflow
180
1811. **No arbitrary waits**: Zero `cy.wait(number)` — use intercepts
1822. **Selectors**: Prefer `data-cy` attributes
1833. **No async/await**: Pure Cypress chaining
1844. **Assertions**: Use `.should()` chains, not manual checks
1855. **Isolation**: Each test independent, use `cy.session()` for auth
186
187## Quick Reference
188
189| Task | Command |
190|------|---------|
191| Open interactive | `npx cypress open` |
192| Run headless | `npx cypress run` |
193| Run specific spec | `npx cypress run --spec "cypress/e2e/login.cy.js"` |
194| Run in browser | `npx cypress run --browser chrome` |
195| Component tests | `npx cypress run --component` |
196| Environment vars | `CYPRESS_BASE_URL=http://localhost:3000 npx cypress run` |
197| Fixtures | `cy.fixture('users.json').then(data => ...)` |
198| File upload | `cy.get('input[type="file"]').selectFile('file.pdf')` |
199| Viewport | `cy.viewport('iphone-x')` or `cy.viewport(1280, 720)` |
200| Screenshot | `cy.screenshot('login-page')` |
201
202## Reference Files
203
204| File | When to Read |
205|------|-------------|
206| `reference/cloud-integration.md` | LambdaTest Cypress CLI, parallel, config |
207| `reference/component-testing.md` | React/Vue/Angular component tests |
208| `reference/custom-commands.md` | Advanced commands, overwrite, TypeScript |
209| `reference/debugging-flaky.md` | Retry-ability, detached DOM, race conditions |
210
211## Advanced Playbook
212
213For production-grade patterns, see `reference/playbook.md`:
214
215| Section | What's Inside |
216|---------|--------------|
217| §1 Production Config | Multi-env configs, setupNodeEvents |
218| §2 Auth with cy.session() | UI login, API login, validation |
219| §3 Page Object Pattern | Fluent page classes, barrel exports |
220| §4 Network Interception | Mock, modify, delay, wait for API |
221| §5 Component Testing | React/Vue mount, stubs, variants |
222| §6 Custom Commands | TypeScript declarations, drag-drop |
223| §7 DB Reset & Seeding | API reset, Cypress tasks, Prisma |
224| §8 Time Control | cy.clock(), cy.tick() |
225| §9 File Operations | Upload, drag-drop, download verify |
226| §10 iframe & Shadow DOM | Content access patterns |
227| §11 Accessibility | cypress-axe, WCAG audits |
228| §12 Visual Regression | Percy, cypress-image-snapshot |
229| §13 CI/CD | GitHub Actions matrix + Cypress Cloud parallel |
230| §14 Debugging Table | 11 common problems with fixes |
231| §15 Best Practices | 15-item production checklist |
232
233## Limitations
234
235- Use this skill only when the task clearly matches its upstream source and local project context.
236- Verify commands, generated code, dependencies, credentials, and external service behavior before applying changes.
237- Do not treat examples as a substitute for environment-specific tests, security review, or user approval for destructive or costly actions.