cypress
This skill equips you with professional Cypress testing strategies and patterns for building reliable end-to-end test suites. Drawn from a curated collection of 240+ Claude Code skills, it delivers actionable guidance on test structure, assertions, and automation workflows to strengthen your QA processes.
Cypress excels at end-to-end testing when you follow core best practices: use data-testid selectors instead of brittle CSS classes, avoid hardcoded waits in favor of Cypress's built-in retry logic, structure tests with clear Given-When-Then patterns, and leverage custom commands to reduce duplication. The skill emphasizes proper element selection strategies, reliable assertions, and network mocking with intercept to simulate API responses. By combining these patterns, you build test suites that are maintainable, fast, and resistant to flakiness.
AI-generated summary based on this skill's SKILL.md
Install
Mindrally/skills/cypress
git clone https://github.com/Mindrally/skills
cp -r skills/cypress ~/.claude/skills/cypressFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
What are the best practices for cypress end-to-end testing?
Cypress excels at end-to-end testing when you follow core best practices: use data-testid selectors instead of brittle CSS classes, avoid hardcoded waits in favor of Cypress's built-in retry logic, structure tests with clear Given-When-Then patterns, and leverage custom commands to reduce duplication. The skill emphasizes proper element selection strategies, reliable assertions, and network mocking with intercept to simulate API responses. By combining these patterns, you build test suites that are maintainable, fast, and resistant to flakiness.
How can I improve test reliability by avoiding flaky patterns and using proper selectors in Cypress?
Cypress test reliability depends on selector quality and async handling. The skill teaches you to prefer data-testid attributes over fragile CSS or XPath selectors, ensuring your tests survive UI refactors. Avoid flaky patterns like hardcoded waits (setTimeout) and instead rely on Cypress's automatic retry mechanism for commands and assertions. Use cy.intercept() to mock network calls predictably, implement proper test isolation so tests don't interfere with each other, and structure authentication via session strategies rather than repeated login steps. These practices eliminate race conditions and timing issues that cause intermittent failures.
What is the recommended approach for structuring and organizing Cypress tests effectively?
Cypress test organization starts with a clear folder structure separating specs by feature or page, then uses custom commands and helper functions to keep tests DRY. The skill recommends the Given-When-Then pattern to make test intent explicit: set up state (Given), perform user actions (When), and verify outcomes (Then). Group related assertions together, use page objects or command libraries to abstract selectors, and implement test isolation so each test runs independently without relying on execution order. This structure makes tests readable, maintainable, and easier to debug when failures occur.
How do I master custom commands and async operations in Cypress?
Cypress custom commands reduce boilerplate and centralize reusable logic—define them in support files and chain them like native Cypress commands. For async operations, understand that Cypress automatically retries commands and assertions, so avoid manual waits; instead, let cy.get(), cy.intercept(), and assertion retries handle timing. The skill covers how to properly chain commands, handle network requests with intercept for API mocking, and structure commands that respect Cypress's async queue. Mastering these patterns lets you write concise, reliable tests that handle real-world timing challenges without flakiness.
What strategies does Cypress offer for test isolation and authentication in e2e testing?
Cypress test isolation ensures each test is independent and can run in any order. The skill teaches session-based authentication strategies—use cy.session() to cache login state across tests, avoiding repeated login steps while maintaining security. Implement test isolation by resetting state between tests, using intercept to mock API responses consistently, and avoiding shared test data. For login testing specifically, authenticate once per session and reuse credentials across related tests rather than logging in for every spec. These strategies speed up test execution, improve reliability, and prevent cascading failures where one test's state breaks subsequent tests.
How does Cypress handle network mocking and API call interception?
Cypress network mocking via cy.intercept() lets you stub API responses, verify requests, and simulate error conditions without hitting real backends. The skill shows how to intercept API calls by URL pattern, return mock data or error statuses, and assert that your app makes the correct requests. This approach isolates your e2e tests from external dependencies, makes them faster and more reliable, and lets you test edge cases like network failures. By combining intercept with proper test structure, you build comprehensive test coverage that validates both UI behavior and API integration without flakiness from real service latency.
SKILL.md
rendered from the published skill — quoted content, verbatim
Cypress Testing Best Practices
You are an expert in Cypress end-to-end testing.
Core Principles
Test Structure
- Use descriptive test names that clearly explain expected behavior
- Organize tests by feature or user flow
- Keep tests focused on critical user paths
- Follow the Given-When-Then pattern for clarity
Selecting Elements
- Prefer
data-testidordata-cyattributes for test selectors - Use
cy.contains()for text-based selection when appropriate - Avoid brittle selectors like CSS classes or tag hierarchies
// Recommended
cy.get('[data-testid="submit-button"]').click();
cy.contains('Submit').click();
// Avoid
cy.get('.btn-primary').click();
Commands and Assertions
- Chain commands fluently for readability
- Use built-in retry-ability; avoid explicit waits
- Prefer
.should()assertions over.then()for automatic retries - Use
.within()to scope commands to a specific element
Custom Commands
- Create custom commands for repeated actions
- Place custom commands
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 1 file
cypress/SKILL.md