Skip to main content
rule

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.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/cypress-accessibility-testing-cursorrules-prompt-file.mdc
Open on GitHub

What 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.mdc

Frontmatter: description, globs, alwaysApply

Step 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

Similar IDE rules

All IDE rules for Testing and QA →

From the same set210

cypress-integration-testing-cursorrules-prompt-file Guides Cursor to generate Cypress integration tests for UI and API flows. Enforces API mocking with cy.intercept and reliable data-testid selectors. ★ 41,024repo stars cypress-e2e-testing-cursorrules-prompt-file This Cursor rule guides an agent in writing Cypress E2E tests for key web-app flows. It detects TypeScript usage and favors stable test selectors. ★ 41,024repo stars cypress-defect-tracking-cursorrules-prompt-file A Cursor rule that turns the agent into a QA engineer: writes Cypress tests tagged by team, category and case ID, and builds reports through qa-shadow-report. ★ 41,024repo stars cypress-api-testing-cursorrules-prompt-file Configures Cursor to write Cypress API tests with schema validation. It detects TypeScript in the project and validates responses using cypress-ajv-schema-validator. ★ 41,024repo stars cursorrules-cursor-ai-wordpress-draft-macos-prompt A Cursor rule that describes the PressThat project: a system tray app that connects to WordPress and creates draft posts. Useful if you work on that app in Cursor. ★ 41,024repo stars cursorrules-cursor-ai-nextjs-14-tailwind-seo-setup A Cursor rule for Next.js 14 development with Tailwind CSS and SEO setup. It guides the AI to generate App Router TypeScript code directly from design screenshots. ★ 41,024repo stars cursor-rules-pack-v2-cursorrules-prompt-file A seven-rule Cursor pack covering dependencies, errors, state, webhooks, and database queries. Use it to guide code changes across a project. ★ 41,024repo stars cursor-ai-react-typescript-shadcn-ui-cursorrules-p A Cursor rule that pushes the agent toward React and TypeScript code written the way shadcn/ui and Tailwind CSS projects expect. ★ 41,024repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor