⏳ This skill is pending AI review.
Scores will appear once the review pipeline completes.
accessibility-testing
>-
Choose how to use this skill
You do not need every option. Choose the path your AI client supports. The stable page stays the same; versioned files are immutable.
1. Native installer
This listing has no registered native installer command. Use the complete package or source fallback below, depending on what your client supports.
Do not guess an installer command or replace an existing version without reviewing the diff.
2. Complete package recommended
Download the ZIP when available. It includes SKILL.md plus the references, security notes and version metadata.
No complete ProSkills package is published for this listing yet.3. Prompt-only
Copy the prompt above when the agent can read the stable page or when you want to adopt the workflow without installing a skill.
Need only the instruction file?
Download SKILL.md only if your client requires a single file. The complete ZIP is safer for a full installation because it preserves the references and release context.
No path installs or executes anything by itself. Your agent still needs access to the project files. Before updating, compare the installed version and review the diff.
// RATINGS
Not yet listed on ClawHub or SkillsMP
// README
QA Skills for AI Agents
QA and test automation skills for Claude Code, Codex, Cursor, Gemini CLI, VS Code, and other agents that support the Agent Skills Standard.
Website: qa-skills.com
npx skills add petrkindlmann/qa-skills
50 skills covering:
- Playwright and Cypress automation
- API, unit, and mobile testing
- Test strategy and risk-based planning
- CI/CD integration and test environments
- Accessibility, security, and compliance
- Visual regression and performance testing
- AI-assisted test generation, bug triage, and agentic browser testing
- Email, payment, and analytics-tracking testing
- Manual test-case management and regression-suite curation
- Chaos engineering, observability, and QA dashboards
Based on patterns from QA automation work across 6+ production sites.
Quick start
Option 1: Install specific skills (recommended)
npx skills add petrkindlmann/qa-skills playwright-automation test-strategy
Option 2: Clone the full repo
git clone https://github.com/petrkindlmann/qa-skills.git .skills/qa-skills
Option 3: Add as a git submodule
git submodule add https://github.com/petrkindlmann/qa-skills.git .skills/qa-skills
Option 4: Manual download
Download individual skill folders from skills/ and place them in your project's .skills/ directory.
Usage
Test the tests

The lab now holds 28 deliberate faults: 19 in the local Shop and 9 in pinned TodoMVC. The motion graphic illustrates the first run of that experiment, with 22 of them. See the application evidence, the current workflow report and the campaign-3 report for observations and limits.
Run checks and produce an evidence report
The full checkout also includes a local QA runner. Install its dependencies with npm ci,
then point it at your application:
npm run qa -- run --project /absolute/path/to/app --goal "Check the critical user flows"
It discovers the project's test command, recommends skills from the goal and repository,
runs bounded checks, and produces report.html, JSON evidence, and concise/detailed logs.
Missing tools, no observed tests, skipped work, and uninterpretable output remain visible.
The host agent uses the selected skills to author tests and make authorized repairs.
To make this part of future coding tasks, explicitly add the project instruction:
npm run qa -- init --project /absolute/path/to/app --wire-agent
This preserves the project's existing config and instructions. Activation depends on the
host reading its AGENTS.md; the runner does not install a background agent. For running
URLs, readiness selectors, CI artifacts, supported reporters, and execution limits, see
the QA runner guide. Installing individual skills does not install the CLI.
Use a domain skill
Ask your AI agent in natural language. Skill selection depends on the host agent; name a skill explicitly when a request could fit several. The examples below show the intended routing.
| You say | Skill activated |
|---|---|
| "Write Playwright tests for our checkout flow" | playwright-automation |
| "Create a QA strategy for this project" | test-strategy |
| "Generate tests from this PRD" | ai-test-generation |
| "This bug keeps happening in prod, classify and triage it" | ai-bug-triage |
| "Set up test reporting in GitHub Actions" | ci-cd-integration + qa-metrics |
| "What should we test before this release?" | release-readiness |
| "Run a visual regression check on the homepage" | visual-testing |
| "Load test our API with 1000 concurrent users" | performance-testing |
| "Check our app for OWASP Top 10 vulnerabilities" | security-testing |
| "Set up synthetic monitoring for critical flows" | synthetic-monitoring |
Skill categories
50 skills across 10 categories. Each skill keeps a lean SKILL.md (heavy code offloaded to references/, loaded on demand) with cross-references to related skills.
Foundation (3)
qa-project-context · qa-start · qa-do — project context template every other skill reads first, new-project QA bootstrap, and the last-resort skill router
Strategy (4)
test-strategy · test-planning · risk-based-testing · exploratory-testing — QA strategy, sprint/release test plans, risk-based prioritization, session-based exploratory testing
Automation (8)
playwright-automation · cypress-automation · selector-drift-recovery · api-testing · unit-testing · mobile-testing · visual-testing · performance-testing — Playwright E2E, Cypress component/E2E, bulk post-refactor selector regeneration, REST/GraphQL, Jest/Vitest/pytest, Appium/Detox, visual regression, k6 load testing and Lighthouse CI
Specialized (7)
accessibility-testing · security-testing · cross-browser-testing · database-testing · email-testing · payment-testing · analytics-tracking-testing — WCAG compliance, OWASP Top 10 + LLM, analytics-driven browser matrices, migration testing, email-flow capture, Stripe/PSP checkout and 3DS, GA4/pixel tracking correctness
AI-augmented QA (6)
ai-test-generation · ai-bug-triage · test-reliability · ai-qa-review · bug-reproduction · agentic-browser-testing — LLM test generation, automated bug triage, flaky test management, test quality review, report-to-failing-test reproduction, goal-driven agentic browser testing
Infrastructure (5)
ci-cd-integration · test-environments · test-data-management · contract-testing · service-virtualization — CI/CD pipelines, environment strategy, data factories, Pact consumer-driven contracts, WireMock/MSW
Metrics (3)
qa-metrics · qa-dashboard · coverage-analysis — quality gates and KPIs, Allure/Grafana/ReportPortal dashboards, coverage-as-ratchet in CI
Process (8)
shift-left-testing · qa-project-bootstrap · release-readiness · quality-postmortem · compliance-testing · qa-report-humanizer · test-case-management · test-suite-curation — shift-left patterns, QA onboarding, go/no-go checklists, blameless postmortems, GDPR/CMP compliance, QA report humanization, manual test-case authoring, regression-suite pruning
Production and observability (3)
testing-in-production · synthetic-monitoring · observability-driven-testing — feature flag validation, scheduled synthetic probes, trace-based test assertions
Knowledge and migration (3)
ai-system-testing · chaos-engineering · test-migration — LLM/AI feature testing, controlled fault injection, framework migration guides (Selenium/Cypress/Jest to modern stacks)
Full skills table
| Skill | Description | Category |
|---|---|---|
qa-project-context | Project context template covering tech stack, test frameworks, CI/CD, environments, quality goals. Every other skill reads this first. | Foundation |
qa-start | Bootstrap QA on a project that has none: chains qa-project-context, test-strategy and test-planning in one guided run, then executes the available checks and records evidence. | Foundation |
qa-do | Last-resort router: maps a plain-language |
// HOW IT'S BUILT
// FILES
4 files shipped with this skill. Inline text is the catalog copy. The upstream link is the source repository.
skills/accessibility-testing/SKILL.md18 KB3e1f07adb2b0upstream ↗
--- name: accessibility-testing description: >- Test for WCAG 2.2 AA compliance with axe-core + Playwright, keyboard navigation audits, screen reader testing, ARIA pattern validation, and legal compliance mapping (ADA, EAA, Section 508). Automated tools catch 30-40% of issues — this skill covers automated and manual testing together. Use when: "accessibility," "a11y," "WCAG," "screen reader," "axe," "keyboard navigation," "ARIA," "ADA compliance." Not for: cookie-consent/GDPR compliance — use compliance-testing; pixel-diff visual regression — use visual-testing. Related: playwright-automation, compliance-testing, visual-testing, ci-cd-integration. license: MIT metadata: author: kindlmann version: "2.1" category: specialized --- <objective> Make an application usable by people who rely on keyboards and assistive technology, and prove it with tests that run in CI. A button that passes `toBeVisible()` can still be unreachable by keyboard; a page with zero axe violations can still be impossible to operate with a screen reader. Automated tools catch 30-40% of accessibility issues — this skill covers the automated scan plus the keyboard, screen reader, and ARIA-state testing that catch the other 60-70%. </objective> ## Discovery Questions Check `.agents/qa-project-context.md` first — if it exists, use it as the foundation and skip anything already answered. **Requirements and compliance** (sets the target level and audit obligations) - What WCAG conformance level is required — A, AA, or AAA? AA is the practical legal default. - What laws apply — ADA, EAA/EN 301 549, Section 508, AODA? Each maps to a WCAG level. - Is there a VPAT or accessibility statement to maintain, or contractual a11y clauses from enterprise/government customers? **Current state** (tells you whether you're auditing or preventing regressions) - Has an audit run before? What were the findings, and what's already in the backlog? - Does the design system carry accessibility guidance and accessible components? **Testing infrastructure** (determines what you can automate vs. must do by hand) - Is automated a11y testing already in CI? - Which screen readers does the team test with — VoiceOver, NVDA, JAWS, TalkBack? ## Core Principles 1. **Automated testing catches 30-40% of issues — no more.** axe-core finds missing alt text, low contrast, missing labels, and invalid ARIA. It cannot tell you whether alt text is meaningful, whether tab order is logical, or whether a custom widget is operable. Passing axe is necessary, not sufficient. Crucially, axe ships **no automated rule** for several WCAG 2.2 success criteria (2.4.11 focus-not-obscured, 2.5.7 dragging movements, and 2.5.8 target-size only partially) — a green axe run does not equal 2.2 AA conformance. 2. **Semantic HTML first, ARIA as last resort.** Native elements (`<button>`, `<nav>`, `<input>`, `<dialog>`) carry built-in semantics, keyboard behavior, and screen reader support. A `<div role="button">` also needs `tabindex`, Enter/Space handlers, focus styles, and ARIA state — all of which a `<button>` gives you free. Reach for ARIA only when no native element fits. 3. **Test in impact order: keyboard, screen reader, automated.** Keyboard issues physically block users from features (highest impact). Screen reader issues confuse with wrong announcements. Automated checks catch the mechanical remainder. Start where the damage is worst, not where the tooling is easiest. 4. **Accessibility is a quality attribute, not a feature.** Test it continuously like performance or security — every new component, every PR. Retrofitting accessibility onto a finished product costs 10-100x more because inaccessible patterns get baked into the component library. 5. **Test with real assistive technology.** Browser DevTools and axe extensions are dev aids, not substitutes for VoiceOver (macOS/iOS), NVDA (Windows), and TalkBack (Android), which each behave differently. Reserve manual AT passes for complex custom widgets. ## Automated Scanning with axe-core + Playwright Install `@axe-core/playwright` pinned to an exact version from `npm view @axe-core/playwright version` (4.14.0 on 2026-10-21; its minor tracks axe-core's, so a new rule set arrives with every bump and must be reviewed, not auto-updated). Wrap it in a reusable `checkAccessibility(page, testInfo, options)` helper that filters to the WCAG tags `['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22aa']`. Require an expected URL and an application-owned readiness assertion before scanning: blank, error, and redirected pages can pass axe. Attach the full results JSON, reject a scan that evaluated no rules, and assert `violations.toHaveLength(0)`. The exported `scanAccessibility` helper returns the violation summary for known-gap baselines; `checkAccessibility` requires zero violations. Loop it over every key page and over interactive states (modal open, menu expanded, signed-in account), not just the default load. For a third-party page you cannot fix, assert the exact set of known rule ids instead of skipping the scan, so a new violation or a fixed one changes the test. Suppress a rule only with a documented justification (a tracking issue or inline comment) and `exclude` third-party widgets you don't own rather than disabling the rule globally. See `references/recipes.md` for the install command, RGAA tag caveat, the full helper, the page-loop and interactive-state specs, rule suppression, and CI integration. ## Manual Testing Checklist Automated scanning is the floor. These checks need a human (or a keyboard-driven Playwright spec — see `references/recipes.md` for the keyboard specs). ### Keyboard navigation audit - [ ] **Tab order is logical** — left-to-right, top-to-bottom for LTR. No surprise focus jumps. - [ ] **All interactive elements reachable** via Tab / Shift+Tab. - [ ] **Focus indicator visible** on every focused element. No `outline: none` without a replacement. - [ ] **Skip link works** — first Tab reveals "Skip to main content"; Enter moves focus to `<main>`. - [ ] **Enter activates** buttons/links; **Space activates** buttons and toggles checkboxes. - [ ] **Escape closes** modals, dropdowns, tooltips; focus returns to the trigger. - [ ] **Arrow keys** navigate within tabs, menus, radio groups, tree views. - [ ] **No keyboard traps** (modal dialogs intentionally trap until dismissed — that's allowed). - [ ] **Custom widgets operable** without a mouse (sliders, date pickers, drag-and-drop). ### Screen reader testing | Screen Reader | OS | Browser | Free? | |--------------|-----|---------|-------| | VoiceOver | macOS/iOS | Safari | Yes (Cmd+F5) | | NVDA | Windows | Firefox/Chrome | Yes | | JAWS | Windows | Chrome/Edge | No | | TalkBack | Android | Chrome | Yes | - [ ] Page title announced on navigation. - [ ] Headings form a navigable outline (h1 → h2 → h3, no skipped levels). - [ ] Images have descriptive alt text (or `alt=""` for decorative). - [ ] Form inputs announce their labels when focused. - [ ] Required fields announced as required; errors associated with their input. - [ ] Live regions announce dynamic content (toasts, loading states). - [ ] Buttons/links announce their purpose (no "click here"). ### Color contrast and visual - [ ] Normal text: **4.5:1** minimum (WCAG AA). Large text (18pt+ / 14pt+ bold): **3:1**. - [ ] UI components and graphical objects: **3:1** against adjacent colors. - [ ] Information never conveyed by color alone — add icons, patterns, or text. ### Form and error accessibility - [ ] Every input has a visible `<label>` tied via `for`/`id` (placeholder is not a label). - [ ] Required fields indicated visually **and** programmatically (`required` / `aria-required`). - [ ] Errors use `aria-describedby` to link to the input and `role="alert"` to announce. - [ ] Focus moves to the first error on submission failure. - [ ] Related fields grouped with `<fieldset>` and `<legend>`. ## WCAG 2.2 Quick Reference ### Level A (must fix) | Criterion | What it means | Common failure | |-----------|--------------|---------------| | 1.1.1 Non-text Content | Images have alt text | `<img>` without `alt` | | 1.3.1 Info and Relationships | Structure via HTML semantics | `<div>` styled as a heading | | 2.1.1 Keyboard | All functionality via keyboard | Custom widget responds only to mouse | | 2.4.1 Bypass Blocks | Skip navigation link | No skip link | | 3.1.1 Language of Page | `<html lang="en">` set | Missing `lang` | | 3.3.1 Error Identification | Errors described in text | Error shown only by red border | | 4.1.2 Name, Role, Value | Custom controls expose name/role | `<div onclick>` with no role | ### Level AA (most common legal requirement) | Criterion | What it means | Common failure | |-----------|--------------|---------------| | 1.4.3 Contrast (Minimum) | 4.5:1 normal, 3:1 large | Light gray on white | | 1.4.4 Resize Text | Scales to 200% without loss | Fixed-height containers clip text | | 1.4.11 Non-text Contrast | UI components 3:1 | Low-contrast input borders | | 2.4.7 Focus Visible | Keyboard focus visible | `outline: none` with no replacement | | 2.5.8 Target Size | Touch targets 24×24px min | Tiny icon buttons | | 3.3.2 Labels or Instructions | Inputs have labels | Placeholder as the only label | | 3.3.8 Accessible Auth | No cognitive function test | CAPTCHA with no alternative | ### Level AAA (nice to have) | Criterion | What it means | |-----------|--------------| | 1.4.6 Contrast (Enhanced) | 7:1 normal text, 4.5:1 large | | 2.4.9 Link Purpose (Link Only) | Link text alone describes destination | | 3.1.5 Reading Level | Lower-secondary education level | ## Accessible Patterns Test on the accessible tree (roles, names, ARIA state), not on CSS. The patterns you need runnable tests for: - **Forms** — error linked via `aria-describedby`, `aria-invalid='true'`, focus on first error. - **Modal/dialog** — `aria-modal='true'`, `aria-labelledby`, focus trapped, Escape returns focus. - **Interactive states** — opened dropdown (`role="menu"` or `role="listbox"`, `aria-expanded`), loading skeleton (`aria-busy='true'` during fetch), toast (`aria-live='polite'`). These carry different ARIA per state, so click to trigger the state change and assert the open-state ARIA — the default page snapshot never exercises them. - **Data tables** — `columnheader` roles, `aria-sort` reflects the active sort. - **Landmarks** — exactly one `main`; `banner`, `navigation`, `contentinfo` present. See `references/patterns.md` for the full runnable tests for every pattern above. ## ARIA Snapshots Playwright's `toMatchAriaSnapshot()` captures the accessible tree as YAML and asserts against it — the fastest way to catch a regression where a visual change silently breaks semantics (a `<div>` restyled to look like a button, a heading demoted to plain text). It checks structure and accessible names, not pixels, so it's complementary to `visual-testing`, not a replacement. Scope snapshots to a stable container; whole-page snapshots over async content go flaky. See `references/patterns.md` for navigation and form snapshot examples. ## Legal Compliance Mapping | Law / Standard | Region | WCAG level required | Enforcement | |---------------|--------|-------------------|------------| | **ADA** | USA | AA (court precedent) | Lawsuits (private right of action) | | **Section 508** | USA (federal) | WCAG 2.0 AA | Federal procurement requirement | | **EAA** | EU | EN 301 549 (WCAG 2.1 AA) | **In force since 28 June 2025.** Member states actively enforcing; private cause of action varies (DE, FR, IE most active). EN 301 549 expected to align with WCAG 2.2 next revision. | | **AODA** | Ontario, Canada | WCAG 2.0 AA | Fines up to $100K/day | | **EN 301 549** | EU | WCAG 2.1 AA | Public procurement requirement | | **Equality Act 2010** | UK | WCAG 2.1 AA (guidance) | Lawsuits | | **ISO/IEC 40500:2025** | International | Equivalent to WCAG 2.2 (Oct 2023) | Useful for procurement/RFP language; freely available from ISO | **Practical target:** if you serve US or EU users, **WCAG 2.2 AA is the target for new development** — the EAA is in force, EN 301 549 is expected to update to 2.2, and ISO/IEC 40500:2025 (published Sept 2025) codifies WCAG 2.2 internationally. WCAG 2.1 AA is the legacy minimum where 2.2 can't be reached immediately. **WCAG 3 status:** W3C published an updated WCAG 3 working draft in March 2026 that renamed "Outcomes" to "Requirements" and moved away from binary pass/fail grading; it lists ~174 requirements. It remains a working draft — Candidate Recommendation is targeted for Q4 2027 and a Recommendation not before 2028. Plan for WCAG 2.2 today; track WCAG 3 but do not test against it yet. **Audit evidence to collect:** automated scan results per page, manual checklists with tester/date, screen reader results with AT versions, accessibility statement, VPAT for enterprise sales, and a remediation plan for known issues. For the full legal/VPAT/consent mapping, see `compliance-testing`. ## Anti-Patterns ### Only automated testing Running axe, finding zero violations, and declaring the product accessible. Automated tools miss 60-70% of real issues and skip several WCAG 2.2 criteria entirely. **Fix:** pair every axe run with the keyboard and screen reader checklist; gate releases on both, not just the scan. ### ARIA overuse Adding `role`, `aria-label`, and `aria-describedby` to elements that already have native semantics, creating double announcements. **Fix:** delete the redundant ARIA and use the native element — a `<button>` never needs `role="button"`. ### Ignoring keyboard users Features that work by mouse and touch but not keyboard — click-only dropdowns, drag-and-drop with no keyboard path, hover-only tooltips. **Fix:** give every mouse interaction a keyboard equivalent and cover it with a `keyboard.spec.ts` test (see `references/recipes.md`). ### Retrofitting accessibility Waiting until the product is "finished," by which point inaccessible patterns are baked into the component library at 10-100x the fix cost. **Fix:** add an axe check to the Definition of Done so every new component is gated on accessibility before merge. ### Treating accessibility as optional Deprioritizing a11y tickets because "nobody complained" — users with disabilities can't complain through a product they can't use, so they leave silently, and US web-accessibility lawsuits have climbed year over year since 2018. **Fix:** track a11y as a release blocker with the same severity rules as functional bugs, and report open a11y issues in the release readiness check. ### Testing only the happy path Scanning only the default page state, missing the modals, expanded dropdowns, error messages, and loading skeletons that carry different ARIA. **Fix:** drive each interactive state in the test (click to open the menu, trigger the fetch) and re-run the scan against the changed DOM. ## Failure Modes | Symptom | Likely cause | Fix or check | |---------|-------------|-------------| | axe finds 0 violations but the page is unusable by keyboard | Automated scans don't test operability or focus order | Run the keyboard audit; add a `keyboard.spec.ts` | | `toMatchAriaSnapshot` is flaky | Dynamic content or list reordering inside the snapshot scope | Scope to a stable container; use a partial snapshot | | Contrast rule passes but text over a gradient/overlay/image is unreadable | axe can't compute contrast against non-solid backgrounds | Check those cases manually or with a contrast picker | | Passing axe but failing a WCAG 2.2 AA audit | axe ships no rule for 2.4.11 / 2.5.7 and only partial 2.5.8 | Manually verify focus-not-obscured, dragging alternatives, and target size | ## Verification Prove the suite actually exercises the page — an a11y test that passes vacuously (wrong URL, axe scanning an error page, snapshot never reached) is worse than none. 1. **Confirm axe is scanning real content.** Point the helper at a page you know has a violation (e.g. temporarily remove a `<label>`) and run it — the test must FAIL and name the rule: ```bash npx playwright test e2e/tests/a11y/pages.spec.ts ``` If a page with a planted defect still passes, AxeBuilder is scanning the wrong DOM (redirect, blank page, or wrong selector) — fix that before trusting any green run. 2. **Confirm the keyboard specs reach the app, not a 404.** Run `npx playwright test e2e/tests/a11y/keyboard.spec.ts` and open the trace for the skip-link test — the first Tab should land on the skip link, not nowhere. A test that "passes" because the page never loaded is a false green. 3. **Confirm the CI gate blocks.** Introduce one serious violation on a branch and push — the `a11y` job must exit non-zero and fail the PR check. Revert after. 4. **Spot-check an ARIA snapshot.** Run `toMatchAriaSnapshot` once with `--update-snapshots`, then again without — the second run must pass. If it flakes, the snapshot scope includes async/reordering content; narrow it to a stable container. ## Done When - axe-core integrated into the E2E suite and run automatically on all key user-facing pages identified in the test strategy. - CI reports zero critical or serious axe violations and blocks merge when any are introduced (see `references/recipes.md` for the workflow). - Keyboard navigation tested end-to-end for all interactive flows (forms, modals, dropdowns, navigation menus). - Interactive-state ARIA verified for at least one dropdown/menu (`aria-expanded` + `role`), one loading region (`aria-busy`), and one live region (`aria-live`). - Color contrast validated for the full brand palette against WCAG AA thresholds (4.5:1 normal text, 3:1 large text and UI components). - Screen reader test notes documented for complex custom widgets (date pickers, data tables, drag-and-drop), including which screen reader and version was used. ## Related Skills - **playwright-automation** — the test runner for both axe scans and keyboard/ARIA snapshot tests; this skill adds the accessibility-specific patterns on top. - **compliance-testing** — legal/regulatory testing including cookie consent (GDPR/CMP), VPAT generation, and EAA/Section 508 reporting. Go there for consent banners and formal compliance documentation; stay here for WCAG conformance testing. - **visual-testing** — pixel-diff screenshot regression. Use it for visual rendering changes; use this skill's ARIA snapshots for semantic-tree regressions and contrast for the a11y-specific color thresholds. - **ci-cd-integration** — running a11y tests in CI and blocking merges on violations. - **risk-based-testing** — prioritizes which pages and components to audit first.skills/accessibility-testing/references/patterns.md6.2 KB68070dd385dbupstream ↗
# Accessible Pattern Tests Runnable Playwright tests for the common accessible UI patterns. The decision prose, checklists, and anti-patterns live in `SKILL.md`; this file holds the code. Every test here asserts on the accessible tree (roles, names, ARIA state) rather than CSS or DOM internals, so it survives styling refactors. ## Accessible Forms ```typescript test('form displays accessible error messages', async ({ page }) => { await page.goto('/contact'); await page.getByRole('button', { name: 'Send message' }).click(); const emailInput = page.getByLabel('Email address'); const emailError = page.getByText('Email is required'); await expect(emailError).toBeVisible(); // Verify aria-describedby links input to error const errorId = await emailError.getAttribute('id'); expect(await emailInput.getAttribute('aria-describedby')).toContain(errorId); await expect(emailInput).toHaveAttribute('aria-invalid', 'true'); await expect(emailInput).toBeFocused(); }); ``` Expected HTML: `<label for="email">Email</label>` + `<input id="email" aria-required="true" aria-invalid="true" aria-describedby="email-error">` + `<p id="email-error" role="alert">Email is required</p>`. ## Modal / Dialog Accessibility ```typescript test('dialog follows ARIA dialog pattern', async ({ page }) => { await page.goto('/dashboard'); const trigger = page.getByRole('button', { name: 'Delete project' }); await trigger.click(); const dialog = page.getByRole('dialog'); await expect(dialog).toBeVisible(); await expect(dialog).toHaveAttribute('aria-labelledby'); await expect(dialog).toHaveAttribute('aria-modal', 'true'); await expect(dialog.locator(':focus')).toBeVisible(); // Focus inside dialog await page.keyboard.press('Escape'); await expect(dialog).toBeHidden(); await expect(trigger).toBeFocused(); // Focus returns to trigger }); ``` ## Interactive States — Opened Dropdown, aria-busy, Live Regions These three states are the most-missed area in practice: components carry different ARIA in each state, and the default page snapshot never exercises them. Click to trigger the state change, then assert the ARIA. ```typescript // Opened dropdown / menu — assert the ARIA of the open state, not just that it opened test('dropdown menu is accessible when open', async ({ page }) => { await page.goto('/dashboard'); const trigger = page.getByRole('button', { name: 'Account' }); await expect(trigger).toHaveAttribute('aria-expanded', 'false'); await trigger.click(); // click to trigger state change await expect(trigger).toHaveAttribute('aria-expanded', 'true'); // A combobox-style listbox uses role="listbox"; a button menu uses role="menu" const menu = page.getByRole('menu'); // or getByRole('listbox') for a select-style widget await expect(menu).toBeVisible(); await expect(menu.getByRole('menuitem')).toHaveCount(3); await page.keyboard.press('Escape'); await expect(menu).toBeHidden(); await expect(trigger).toHaveAttribute('aria-expanded', 'false'); await expect(trigger).toBeFocused(); }); ``` ```typescript // Loading skeleton announces busy state via aria-busy test('loading skeleton sets aria-busy while fetching', async ({ page }) => { await page.goto('/reports'); const region = page.getByRole('region', { name: 'Report data' }); await page.getByRole('button', { name: 'Run report' }).click(); // triggers fetch await expect(region).toHaveAttribute('aria-busy', 'true'); // skeleton is announced as busy await expect(region).toHaveAttribute('aria-busy', 'false'); // resolves when data lands await expect(region.getByRole('table')).toBeVisible(); }); ``` ```typescript // Toast / status message announced via a polite live region test('toast notifications are announced', async ({ page }) => { await page.goto('/settings'); const toastRegion = page.locator("[aria-live='polite']"); await expect(toastRegion).toBeAttached(); await page.getByRole('button', { name: 'Save changes' }).click(); await expect(toastRegion.getByText('Settings saved')).toBeVisible(); }); ``` ## Data Tables ```typescript test('table has proper headers and sort state', async ({ page }) => { await page.goto('/users'); const table = page.getByRole('table', { name: 'User accounts' }); await expect(table.getByRole('columnheader')).toHaveCount(5); const nameHeader = page.getByRole('columnheader', { name: 'Name' }); await nameHeader.click(); await expect(nameHeader).toHaveAttribute('aria-sort', 'ascending'); }); ``` ## Navigation Landmarks ```typescript test('page has required landmarks', async ({ page }) => { await page.goto('/dashboard'); await expect(page.getByRole('banner')).toBeVisible(); // <header> await expect(page.getByRole('navigation')).toBeVisible(); // <nav> await expect(page.getByRole('main')).toBeVisible(); // <main> await expect(page.getByRole('main')).toHaveCount(1); // Exactly one <main> await expect(page.getByRole('contentinfo')).toBeVisible(); // <footer> }); ``` ## ARIA Snapshots (Playwright) Playwright's `toMatchAriaSnapshot()` captures the accessible tree as YAML and asserts against it. Use it to catch regressions where a visual change silently breaks semantics — a `<div>` restyled to look like a button, a heading demoted to plain text. It asserts structure and accessible names, not pixels. ```typescript test('navigation has correct accessible structure', async ({ page }) => { await page.goto('/dashboard'); await expect(page.getByRole('navigation', { name: 'Main' })).toMatchAriaSnapshot(` - navigation "Main": - link "Dashboard" - link "Projects" - link "Settings" - link "Help" `); }); test('form has correct accessible structure', async ({ page }) => { await page.goto('/settings'); await expect(page.getByRole('form', { name: 'Profile settings' })).toMatchAriaSnapshot(` - form "Profile settings": - textbox "Display name" - textbox "Email address" - combobox "Time zone" - checkbox "Email notifications" - button "Save changes" `); }); ``` ARIA snapshots are order-sensitive and include dynamic content. If a list reorders or content is async, the snapshot goes flaky — scope it to a stable container or use a partial snapshot rather than capturing a whole dynamic page.skills/accessibility-testing/references/recipes.md8.5 KB8f4d5cc87e08upstream ↗
# axe-core Setup, Keyboard Specs, and CI Runnable recipes for automated scanning and keyboard auditing. Decision prose lives in `SKILL.md`. ## Install ```bash # Pin the exact current release; the minor tracks axe-core's rule set (4.14.0 on 2026-10-21) npm view @axe-core/playwright version npm install --save-dev --save-exact @axe-core/[email protected] ``` > **RGAA tag caveat:** Several best-practice rules (`focus-order-semantics`, `region`, > `skip-link`, `table-duplicate-name`) are also tagged `RGAAv4` (the French national standard). > If you don't intend to test against RGAA, filter by the explicit WCAG tags shown below and > avoid the `best-practice` tag, which pulls in RGAA-specific rules you didn't ask for. ## Reusable Helper ```typescript // e2e/helpers/a11y.ts import { type Page, type TestInfo, expect } from '@playwright/test'; import AxeBuilder from '@axe-core/playwright'; interface A11yOptions { expectedURL: string | RegExp; ready: () => Promise<void>; // assert the app-owned page/state completion signal tags?: string[]; exclude?: string[]; disableRules?: string[]; } export async function scanAccessibility( page: Page, testInfo: TestInfo, options: A11yOptions ) { if (!options?.expectedURL || typeof options.ready !== 'function') { throw new Error('Accessibility scan requires expectedURL and an application readiness assertion'); } // A blank/error/login page can pass axe. Prove the intended page and state first. await expect(page).toHaveURL(options.expectedURL); await options.ready(); let builder = new AxeBuilder({ page }) .withTags(options.tags ?? ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22aa']); for (const sel of options.exclude ?? []) builder = builder.exclude(sel); if (options.disableRules?.length) builder = builder.disableRules(options.disableRules); const results = await builder.analyze(); await testInfo.attach('a11y-results', { body: JSON.stringify(results, null, 2), contentType: 'application/json', }); // This guards scanner execution only; the URL/readiness checks establish page identity. expect(results.passes.length + results.violations.length + results.incomplete.length, 'axe evaluated no rules').toBeGreaterThan(0); return results.violations.map((v) => ({ rule: v.id, impact: v.impact, description: v.description, helpUrl: v.helpUrl, elements: v.nodes.map((n) => n.html).slice(0, 5), })); } export async function checkAccessibility( page: Page, testInfo: TestInfo, options: A11yOptions ): Promise<void> { const violations = await scanAccessibility(page, testInfo, options); expect(violations, `${violations.length} a11y violations:\n${JSON.stringify(violations, null, 2)}`) .toHaveLength(0); } ``` The WCAG 2.2 AA target is cumulative: retain the WCAG 2.0 and 2.1 A/AA tags as well as `wcag22aa`. Selecting only `wcag22aa` does not select earlier criteria. A nonempty rule count proves scanner activity, not that the intended page loaded. Supply an exact approved URL and an application-owned completion assertion; adapt the example test IDs to your app. ## Using in Tests ```typescript // e2e/tests/a11y/pages.spec.ts import { test, expect } from '@playwright/test'; import { checkAccessibility } from '../../helpers/a11y'; test.describe('Accessibility - public pages', () => { for (const { name, path } of [ { name: 'Home', path: '/' }, { name: 'Login', path: '/login' }, { name: 'Pricing', path: '/pricing' }, { name: 'Sign Up', path: '/signup' }, ]) { test(`${name} page has no a11y violations`, async ({ page, baseURL }, testInfo) => { if (!baseURL) throw new Error('Configure the approved application baseURL'); const expectedURL = new URL(path, baseURL).href; await page.goto(expectedURL); await checkAccessibility(page, testInfo, { expectedURL, ready: async () => { await expect(page.getByTestId(`page-${name.toLowerCase().replaceAll(' ', '-')}-ready`)) .toHaveAttribute('data-state', 'ready'); await expect(page.getByRole('heading', { name, exact: true })).toBeVisible(); }, }); }); } }); test.describe('Accessibility - interactive states', () => { test('modal dialog is accessible when open', async ({ page, baseURL }, testInfo) => { if (!baseURL) throw new Error('Configure the approved application baseURL'); const expectedURL = new URL('/dashboard', baseURL).href; await page.goto(expectedURL); await page.getByRole('button', { name: 'Create project' }).click(); await checkAccessibility(page, testInfo, { expectedURL, ready: async () => { await expect(page.getByRole('dialog', { name: 'Create project' })).toBeVisible(); await expect(page.getByTestId('project-dialog-ready')).toHaveAttribute('data-state', 'ready'); }, }); }); }); ``` ## Known-Gap Baseline for Pages You Cannot Fix Vendored or upstream pages often ship real violations. Do not disable the scan; pin the exact set so the test still moves when a rule appears or disappears: ```typescript import { scanAccessibility } from '../../helpers/a11y'; const upstreamGaps = ['button-name', 'label']; // unnamed row controls in the pinned TodoMVC const violations = await scanAccessibility(page, testInfo, { expectedURL: new URL('/', baseURL).href, ready: async () => { // Arrange the populated state first: an empty TodoMVC has no row controls to scan. await expect(page.getByRole('heading', { name: 'todos', exact: true })).toBeVisible(); await expect(page.locator('.todo-list > li')).toHaveCount(2); }, }); expect([...new Set(violations.map((v) => v.rule))].sort()).toEqual(upstreamGaps); ``` ## Rule Suppression Suppress rules only with documented justification — a tracking issue or inline comment so the suppression is reviewable and removable: ```typescript await checkAccessibility(page, testInfo, { expectedURL: new URL('/support', baseURL).href, ready: async () => { await expect(page.getByTestId('support-ready')).toHaveAttribute('data-state', 'ready'); }, disableRules: ['frame-title'], // Third-party chat widget; tracked in PROJ-4521 exclude: ['#third-party-analytics-widget'], }); ``` ## Keyboard Audit Specs ```typescript // e2e/tests/a11y/keyboard.spec.ts import { test, expect } from '@playwright/test'; test('skip link moves focus to main content', async ({ page }) => { await page.goto('/'); await page.keyboard.press('Tab'); const skipLink = page.getByRole('link', { name: /skip to (main )?content/i }); await expect(skipLink).toBeFocused(); await page.keyboard.press('Enter'); await expect(page.getByRole('main')).toBeFocused(); }); test('modal traps focus and returns it on close', async ({ page }) => { await page.goto('/dashboard'); const trigger = page.getByRole('button', { name: 'Create project' }); await trigger.click(); const dialog = page.getByRole('dialog'); await expect(dialog).toBeVisible(); // Escape closes and returns focus to trigger await page.keyboard.press('Escape'); await expect(dialog).toBeHidden(); await expect(trigger).toBeFocused(); }); test('form can be completed entirely by keyboard', async ({ page }) => { await page.goto('/signup'); await page.keyboard.press('Tab'); await page.keyboard.type('Jane Doe'); await page.keyboard.press('Tab'); await page.keyboard.type('[email protected]'); await page.keyboard.press('Tab'); await page.keyboard.type('SecureP@ss123'); await page.keyboard.press('Tab'); await page.keyboard.press('Space'); // Toggle checkbox await expect(page.getByRole('checkbox', { name: /terms/i })).toBeChecked(); await page.keyboard.press('Tab'); await page.keyboard.press('Enter'); // Submit await expect(page).toHaveURL(/\/welcome/); }); ``` ## CI Integration ```yaml # .github/workflows/a11y.yml name: Accessibility Tests on: push: { branches: [main] } pull_request: { branches: [main] } jobs: a11y: runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: { node-version: 20, cache: npm } - run: npm ci - run: npx playwright install --with-deps chromium - run: npm run build && npm start & - run: npx wait-on http://localhost:3000 --timeout 60000 - run: npx playwright test e2e/tests/a11y/ - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: name: a11y-report # upload-artifact takes newline-separated paths via a block scalar path: | test-results/ playwright-report/ retention-days: 14 ```README.mdupstream ↗
Contents are not inlined in the catalog. Open the upstream file.
Plain-text copy, no login: /skill-bundles/petrkindlmann-qa-skills-skills-accessibility-testing.md