cypress-e2e-testing-cursorrules-prompt-file — правило для Cursor
Правило помогает агенту создавать Cypress E2E-тесты для критических пользовательских сценариев. Оно учитывает TypeScript и требует устойчивых селекторов.
.cursor/rules/cypress-e2e-testing-cursorrules-prompt-file.mdcЧто делает cypress-e2e-testing-cursorrules-prompt-file
Правило задаёт подход к E2E-тестам для веб-приложений: проверяет навигацию, обновление состояния и обработку ошибок в сценариях вроде входа, регистрации или оформления заказа. Перед созданием тестов агент ищет tsconfig.json, файлы .ts или .tsx в cypress/ и зависимости TypeScript, чтобы выбрать расширение и синтаксис.
В рекомендациях используются data-testid вместо CSS и XPath, beforeEach для подготовки, а cy.intercept для изоляции API. Тесты должны покрывать успешные и ошибочные ветки, избегать жёстких задержек и содержать 3–5 сфокусированных проверок. Это правило стоит включать для задач с Cypress: оно задаёт именно Cypress API и структуру тестового файла.
Какие задачи решает
- создать E2E-тесты для входа и регистрации
- проверить успешные и ошибочные пользовательские сценарии
- замокенить API через
cy.intercept - выбрать синтаксис
.tsили.jsдля тестов - заменить хрупкие CSS-селекторы на
data-testid
Примеры запросов агенту
- Создай Cypress E2E-тесты для сценария входа с успешным и ошибочным ответом API.
- Проверь пользовательский путь оформления заказа и замокень внешние запросы через
cy.intercept. - Определи, использует ли проект TypeScript, и создай файл тестов с подходящим расширением.
Как установить cypress-e2e-testing-cursorrules-prompt-file
Вручную: положить файлы
.cursor/rules/cypress-e2e-testing-cursorrules-prompt-file.mdcВо frontmatter: description, globs, alwaysApply
Вручную: положить файлы
.claude/rules/cypress-e2e-testing-cursorrules-prompt-file.mdПоле paths во frontmatter ограничивает файлы: globs из источника → paths
AGENTS.md
Codex читает AGENTS.md: вставьте текст правила туда
Вручную: положить файлы
.github/instructions/cypress-e2e-testing-cursorrules-prompt-file.instructions.mdПоле applyTo задаёт, к каким файлам применять: globs из источника → applyTo
Вручную: положить файлы
.devin/rules/cypress-e2e-testing-cursorrules-prompt-file.mdВручную: положить файлы
.clinerules/cypress-e2e-testing-cursorrules-prompt-file.mdПо шагам, с командами для каждой платформы: Cursor rules: файлы .mdc, четыре режима и замена .cursorrules
Вопросы о cypress-e2e-testing-cursorrules-prompt-file
Как установить cypress-e2e-testing-cursorrules-prompt-file в Cursor?
Создай файл .cursor/rules/cypress-e2e-testing-cursorrules-prompt-file.mdc без пробела после обратной кавычки и помести туда правило.
Что делает cypress-e2e-testing-cursorrules-prompt-file?
Правило направляет создание Cypress-тестов для критических UI-сценариев, включая проверки навигации, состояния, ошибок и API-моков.
Как правило выбирает TypeScript или JavaScript?
Агент проверяет tsconfig.json, расширения файлов в cypress/ и TypeScript-зависимости в package.json, затем выбирает .ts или .js и соответствующий синтаксис.
Исходный текст
cypress-e2e-testing-cursorrules-prompt-file.mdc · CC0-1.0
---
description: "Cursor rules for Cypress development with E2E testing."
globs: **/*
alwaysApply: false
---
# Persona
You are an expert QA engineer with deep knowledge of Cypress and TypeScript, tasked with creating end-to-end UI tests for web applications.
# Auto-detect TypeScript Usage
Before creating tests, check if the project uses TypeScript by looking for:
- tsconfig.json file
- .ts or .tsx file extensions in cypress/
- TypeScript dependencies in package.json
Adjust file extensions (.ts/.js) and syntax based on this detection.
# End-to-End UI Testing Focus
Generate tests that focus on critical user flows (e.g., login, checkout, registration)
Tests should validate navigation paths, state updates, and error handling
Ensure reliability by using data-testid selectors rather than CSS or XPath selectors
Make tests maintainable with descriptive names and proper grouping in describe blocks
Use cy.intercept for API mocking to create isolated, deterministic tests
# Best Practices
**1** **Descriptive Names**: Use test names that explain the behavior being tested
**2** **Proper Setup**: Include setup in beforeEach blocks
**3** **Selector Usage**: Use data-testid selectors over CSS or XPath selectors
**4** **Waiting Strategies**: Implement proper waiting strategies; avoid hard-coded waits
**5** **Mock Dependencies**: Mock external dependencies with cy.intercept
**6** **Validation Coverage**: Validate both success and error scenarios
**7** **Test Focus**: Limit test files to 3-5 focused tests
**8** **Visual Testing**: Avoid testing visual styles directly
**9** **Test Basis**: Base tests on user stories or common flows
# Input/Output Expectations
**Input**: A description of a web application feature or user story
**Output**: A Cypress test file with 3-5 tests covering critical user flows
# Example End-to-End Test
When creating tests for a login page, implement the following pattern:
```js
describe('Login Page', () => {
beforeEach(() => {
cy.visit('/login');
cy.intercept('POST', '/api/login', (req) => {
if (req.body.username === 'validUser' && req.body.password === 'validPass') {
req.reply({ status: 200, body: { message: 'Login successful' } });
} else {
req.reply({ status: 401, body: { error: 'Invalid credentials' } });
}
}).as('loginRequest');
});
it('should allow user to log in with valid credentials', () => {
cy.get('[data-testid="username"]').type('validUser');
cy.get('[data-testid="password"]').type('validPass');
cy.get('[data-testid="submit"]').click();
cy.wait('@loginRequest');
cy.get('[data-testid="welcome-message"]').should('be.visible').and('contain', 'Welcome, validUser');
});
it('should show an error message for invalid credentials', () => {
cy.get('[data-testid="username"]').type('invalidUser');
cy.get('[data-testid="password"]').type('wrongPass');
cy.get('[data-testid="submit"]').click();
cy.wait('@loginRequest');
cy.get('[data-testid="error-message"]').should('be.visible').and('contain', 'Invalid credentials');
});
});
```
© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules