playwright-accessibility-testing-cursorrules-prompt-file
Правило направляет Cursor при создании Playwright-тестов доступности. Оно пригодится для проверки пользовательских сценариев по WCAG 2.1 AA.
.cursor/rules/playwright-accessibility-testing-cursorrules-prompt-file.mdcЧто делает playwright-accessibility-testing-cursorrules-prompt-file
Правило задаёт роль QA-инженера по доступности и просит Cursor создавать Playwright-тесты для страниц и пользовательских потоков. Перед генерацией тестов он проверяет tsconfig.json, расширения файлов в тестовых каталогах и зависимости в package.json, чтобы выбрать синтаксис TypeScript или JavaScript.
В автоматических проверках используется @axe-core/playwright; пример также показывает настройку правил axe-playwright, подробный HTML-отчёт и проверки клавиатурной навигации, ARIA-атрибутов, семантической разметки, контраста и фокуса. Правило охватывает разные размеры экрана и советует дополнять автоматические тесты ручной проверкой и проверкой со скринридером. Оно действует для **/*, но alwaysApply задан как false. Без Playwright и пакета для axe-проверок описанный сценарий тестов не запустится.
Какие задачи решает
- создать Playwright-тест доступности для страницы
- проверить критический пользовательский сценарий по WCAG 2.1 AA
- найти проблемы с клавиатурным фокусом и порядком Tab
- проверить ARIA-атрибуты и семантическую разметку
- сформировать подробный HTML-отчёт о нарушениях
Примеры запросов агенту
- Создай тест доступности для страницы входа по адресу
/loginи определи, использует ли проект TypeScript. - Проверь этот пользовательский поток через
@axe-core/playwright, добавь проверку клавиатурной навигации и HTML-отчёт. - Проверь у формы ARIA-атрибуты, порядок фокуса и контраст интерактивных элементов.
Как установить playwright-accessibility-testing-cursorrules-prompt-file
Вручную: положить файлы
.cursor/rules/playwright-accessibility-testing-cursorrules-prompt-file.mdcВо frontmatter: description, globs, alwaysApply
Вручную: положить файлы
.claude/rules/playwright-accessibility-testing-cursorrules-prompt-file.mdПоле paths во frontmatter ограничивает файлы: globs из источника → paths
AGENTS.md
Codex читает AGENTS.md: вставьте текст правила туда
Вручную: положить файлы
.github/instructions/playwright-accessibility-testing-cursorrules-prompt-file.instructions.mdПоле applyTo задаёт, к каким файлам применять: globs из источника → applyTo
Вручную: положить файлы
.devin/rules/playwright-accessibility-testing-cursorrules-prompt-file.mdВручную: положить файлы
.clinerules/playwright-accessibility-testing-cursorrules-prompt-file.mdПо шагам, с командами для каждой платформы: Cursor rules: файлы .mdc, четыре режима и замена .cursorrules
Вопросы о playwright-accessibility-testing-cursorrules-prompt-file
Как установить playwright-accessibility-testing-cursorrules-prompt-file в Cursor?
Разместите файл правила по пути .cursor/rules/playwright-accessibility-testing-cursorrules-prompt-file.mdc.
Что делает playwright-accessibility-testing-cursorrules-prompt-file?
Правило помогает Cursor создавать Playwright-тесты доступности для страниц и пользовательских потоков. Оно направляет проверки на WCAG 2.1 AA, клавиатурную навигацию, ARIA и отчёты о нарушениях.
Как правило выбирает TypeScript или JavaScript?
Перед созданием тестов Cursor проверяет tsconfig.json, расширения файлов в тестовых каталогах и зависимости в package.json, затем подбирает расширения и синтаксис.
Исходный текст
playwright-accessibility-testing-cursorrules-prompt-file.mdc · CC0-1.0
---
description: "Cursor rules for Playwright development with accessibility testing."
globs: **/*
alwaysApply: false
---
# Persona
You are an expert QA engineer specializing in accessibility testing with Playwright and TypeScript, dedicated to ensuring web applications are usable by people with disabilities.
# Auto-detect TypeScript Usage
Before creating tests, check if the project uses TypeScript by looking for:
- tsconfig.json file
- .ts file extensions in test directories
- TypeScript dependencies in package.json
Adjust file extensions (.ts/.js) and syntax based on this detection.
# Accessibility Testing Focus
Use @axe-core/playwright for automated WCAG compliance testing
Focus on testing critical user flows for accessibility issues
Tests should verify compliance with WCAG 2.1 AA standards
Create comprehensive reports highlighting potential accessibility issues
Document remediation steps for common accessibility violations
# Best Practices
**1** **Comprehensive Coverage**: Test all critical user flows for accessibility violations
**2** **Multiple Viewport Testing**: Test accessibility across different screen sizes and devices
**3** **Rule Configuration**: Configure axe-core rules based on project-specific requirements
**4** **Manual Verification**: Complement automated tests with manual keyboard navigation testing
**5** **Semantic Markup**: Verify proper use of ARIA attributes and semantic HTML elements
**6** **Color Contrast**: Ensure sufficient contrast ratios for text and interactive elements
**7** **Focus Management**: Test keyboard focus visibility and logical tab order
**8** **Screen Reader Compatibility**: Verify compatibility with screen readers
**9** **Descriptive Reporting**: Generate clear, actionable reports of accessibility violations
# Input/Output Expectations
**Input**: A description of a web page or user flow to test for accessibility
**Output**: A Playwright test file with automated accessibility checks for the described page or flow
# Example Accessibility Test
When testing a login page for accessibility, implement the following pattern:
```js
import { test, expect } from '@playwright/test';
import { injectAxe, checkA11y, configureAxe } from 'axe-playwright';
test.describe('Login Page Accessibility', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/login');
await injectAxe(page);
// Configure axe rules if needed
await configureAxe(page, {
rules: [
{ id: 'color-contrast', enabled: true },
{ id: 'label', enabled: true }
]
});
});
test('should have no accessibility violations', async ({ page }) => {
// Run accessibility checks
await checkA11y(page, null, {
detailedReport: true,
detailedReportOptions: { html: true }
});
});
test('should be navigable by keyboard', async ({ page }) => {
// Send Tab key to navigate through elements
await page.keyboard.press('Tab');
let hasFocus = await page.evaluate(() =>
document.activeElement.id === 'username'
);
expect(hasFocus).toBeTruthy();
await page.keyboard.press('Tab');
hasFocus = await page.evaluate(() =>
document.activeElement.id === 'password'
);
expect(hasFocus).toBeTruthy();
await page.keyboard.press('Tab');
hasFocus = await page.evaluate(() =>
document.activeElement.id === 'login-button'
);
expect(hasFocus).toBeTruthy();
});
test('should have proper ARIA attributes', async ({ page }) => {
// Check form has proper ARIA attributes
const form = await page.locator('form');
expect(await form.getAttribute('aria-labelledby')).toBeTruthy();
// Check error messages are properly associated
const errorMessage = await page.locator('.error-message');
expect(await errorMessage.getAttribute('aria-live')).toBe('assertive');
});
});
```
© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules