cypress
БесплатноБез исполняемых скриптовНе проверенCypress end-to-end testing best practices for web applications, covering test structure, commands, and reliability patterns.
от Mindrally★ 323 звезды на GitHubОб этом скилле
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 in
cypress/support/commands.js - Document custom commands with JSDoc comments
Cypress.Commands.add('login', (email, password) => {
cy.session([email, password], () => {
cy.visit('/login');
cy.get('[data-testid="email"]').type(email);
cy.get('[data-testid="password"]').type(password);
cy.get('[data-testid="submit"]').click();
cy.url().should('include', '/dashboard');
});
});
Handling Async Operations
- Cypress commands are automatically queued; don't mix with async/await
- Use
cy.intercept()to mock or wait for network requests - Use
cy.wait()with aliases, not arbitrary timeouts
cy.intercept('GET', '/api/users').as('getUsers');
cy.visit('/users');
cy.wait('@getUsers');
cy.get('[data-testid="user-list"]').should('be.visible');
Test Isolation
- Each test should be independent and repeatable
- Use
beforeEachhooks for setup - Use
cy.session()for efficient authentication
Anti-Patterns to Avoid
- Using
cy.wait(5000)with arbitrary timeouts - Testing third-party sites you don't control
- Writing overly long tests that test multiple features
- Relying on the state from previous tests
Установить cypress в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл cypress?
Cypress end-to-end testing best practices for web applications, covering test structure, commands, and reliability patterns.
Как установить скилл cypress?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cypress запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
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…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от 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…
от Anthropic