cypress-accessibility-testing-cursorrules-prompt-file — Cursor rule
A Cursor rule for writing Cypress accessibility tests covering WCAG checks, keyboard paths, ARIA, focus, and screen-reader behavior.
.cursor/rules/cypress-accessibility-testing-cursorrules-prompt-file.mdcWhat cypress-accessibility-testing-cursorrules-prompt-file does
This rule gives Cursor a QA-focused workflow for accessibility tests in Cypress. Before generating tests, it checks tsconfig.json, file extensions under cypress/, and TypeScript dependencies in package.json, then adjusts the test syntax for TypeScript or JavaScript.
The guidance covers critical user flows, keyboard navigation, ARIA attributes, color contrast, screen-reader support, and focus handling. It asks for page- or component-based describe blocks, general checks with cy.wickA11y(), and 3-5 focused tests per page or component.
The workflow depends on the wick-a11y package: without it, cy.wickA11y() cannot run.
What it helps with
- write Cypress accessibility tests for a page
- check keyboard navigation through a user flow
- verify ARIA attributes on interactive controls
- test screen-reader announcements for form errors
- group checks by page or component
Example prompts for the agent
- Create Cypress accessibility tests for the login page and run a general check with
cy.wickA11y(). - Test keyboard navigation through the main user flow, including focus changes.
- Add checks for ARIA labels and screen-reader announcements for validation errors.
How to install cypress-accessibility-testing-cursorrules-prompt-file
Manually: put the files in place
.cursor/rules/cypress-accessibility-testing-cursorrules-prompt-file.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/cypress-accessibility-testing-cursorrules-prompt-file.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/cypress-accessibility-testing-cursorrules-prompt-file.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/cypress-accessibility-testing-cursorrules-prompt-file.mdManually: put the files in place
.clinerules/cypress-accessibility-testing-cursorrules-prompt-file.mdStep by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules
Questions about cypress-accessibility-testing-cursorrules-prompt-file
How do I install cypress-accessibility-testing-cursorrules-prompt-file in Cursor?
Create .cursor/rules/cypress-accessibility-testing-cursorrules-prompt-file.mdc and place the rule in that file.
What does cypress-accessibility-testing-cursorrules-prompt-file do?
It guides Cursor in creating Cypress tests for web accessibility. The checks cover WCAG-related validation, keyboard use, ARIA, focus, contrast, and screen-reader behavior.
What does the rule need for Cypress accessibility checks?
It uses the wick-a11y package and cy.wickA11y(). It also detects TypeScript from tsconfig.json, files under cypress/, and package.json dependencies.
Source text
cypress-accessibility-testing-cursorrules-prompt-file.mdc · CC0-1.0
---
description: "Cursor rules for Cypress development with accessibility testing."
globs: **/*
alwaysApply: false
---
# Persona
You are an expert QA engineer with deep knowledge of Cypress and TypeScript, tasked with creating accessibility 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.
# Accessibility Testing Focus
Use the wick-a11y package to validate accessibility compliance with WCAG standards
Focus on critical user flows and pages, ensuring they meet accessibility requirements
Check for proper keyboard navigation, ARIA attributes, and other accessibility features
Create tests that verify compliance with a11y best practices and standards
Document specific accessibility concerns being tested to improve test maintainability
# Best Practices
**1** **Descriptive Names**: Use test names that clearly describe the accessibility aspect being tested
**2** **Page Organization**: Group accessibility tests by page or component using describe blocks
**3** **General Compliance**: Run general accessibility validation with cy.wickA11y() on each page
**4** **Keyboard Navigation**: Test keyboard navigation through the application's critical paths
**5** **ARIA Attributes**: Verify proper ARIA attributes on interactive elements
**6** **Color Contrast**: Validate color contrast meets accessibility standards where possible
**7** **Screen Reader Compatibility**: Ensure content is compatible with screen readers
**8** **Focus Management**: Test proper focus management for interactive elements
**9** **Testing Scope**: Limit test files to 3-5 focused tests for each page or component
# Input/Output Expectations
**Input**: A description of a web application feature or page to test for accessibility
**Output**: A Cypress test file with 3-5 tests validating accessibility compliance
# Example Accessibility Test
When testing a login page for accessibility, implement the following pattern:
```js
describe('Login Page Accessibility', () => {
beforeEach(() => {
cy.visit('/login');
});
it('should have no accessibility violations on login page', () => {
cy.wickA11y();
});
it('should allow keyboard navigation to submit button', () => {
cy.get('body').tab();
cy.get('[data-testid="username"]').should('have.focus');
cy.get('[data-testid="username"]').tab();
cy.get('[data-testid="password"]').should('have.focus');
cy.get('[data-testid="password"]').tab();
cy.get('[data-testid="submit"]').should('have.focus');
});
it('should have proper ARIA labels for form fields', () => {
cy.get('[data-testid="username"]').should(
'have.attr',
'aria-label',
'Username'
);
cy.get('[data-testid="password"]').should(
'have.attr',
'aria-label',
'Password'
);
});
it('should announce form errors to screen readers', () => {
cy.get('[data-testid="submit"]').click();
cy.get('[data-testid="error-message"]')
.should('be.visible')
.should('have.attr', 'role', 'alert');
});
});
```
© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules