Skip to content

Add accessibility testing with @axe-core/playwright#141

Draft
rameziophobia wants to merge 10 commits into
ramez/a11y-samplefrom
claude/setup-a11y-subpackage-56910
Draft

Add accessibility testing with @axe-core/playwright#141
rameziophobia wants to merge 10 commits into
ramez/a11y-samplefrom
claude/setup-a11y-subpackage-56910

Conversation

@rameziophobia

Copy link
Copy Markdown
Collaborator

Summary

This PR introduces a complete accessibility testing framework to shaka-perf using @axe-core/playwright. It adds a new shaka-accessibility package with CLI integration, configuration management, and artifact generation for accessibility scanning.

Key Changes

  • New shaka-accessibility package with:

    • runner.ts: Core axe scanning engine that runs accessibility tests against experiment server, manages browser lifecycle, handles concurrent viewport scanning with configurable limits, and writes JSON artifacts
    • config.ts: Zod-based configuration schemas for global and per-test axe settings with merge logic (tags replace, disableRules union, includeRules replace, viewports replace)
    • types.ts: TypeScript types for violations, scans, and artifacts with stable on-disk format
    • cli/program.ts: Commander-based CLI command for standalone axe runs
    • cli/run.ts: Command handler that loads tests via shaka-shared, resolves config, and orchestrates the run
  • Configuration features:

    • Global defaults: WCAG 2A/2AA tags, mobile (375×667) and desktop (1280×800) viewports, Chromium browser
    • Per-test overrides for viewports, tags, rules, and skip flag
    • Allowlist mode via includeRules (requirement 3.6)
    • failOnViolation flag to control CI gating
  • Runner implementation:

    • Single browser instance for entire run with per-test context isolation (requirement 3.6)
    • Concurrent viewport scanning with configurable async limit
    • Error isolation: per-test failures don't block other tests
    • Artifact output at <resultsRoot>/<slug>/axe-report.json matching compare layout (requirement 3.7)
    • Detailed violation reporting with node targets, HTML, and failure summaries
  • Integration with shaka-perf:

    • Added TestType.Accessibility enum value
    • Added AbTestAxeConfig interface to test options
    • Integrated createAxeCommand into main CLI
    • Updated shaka-perf to depend on shaka-accessibility
  • Package metadata: Updated descriptions, added exports for CLI subpath, configured public npm publishing

Notable Implementation Details

  • Browser launch errors are handled gracefully with per-test error entries rather than crashing
  • Test preparation mirrors visreg semantics (navigate, invoke testFn for DOM state)
  • Violation normalization preserves axe-core's nested target arrays for iframe/shadow DOM scenarios
  • Concurrent scanning uses a simple work-stealing queue pattern with configurable worker count
  • Artifact format is stable for v2 harvest integration

https://claude.ai/code/session_019pEe9aVhJNZEhoqtAq9DFi

@coderabbitai

coderabbitai Bot commented Apr 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9a8cebae-6646-46fc-a44a-78918c6acbea

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/setup-a11y-subpackage-56910

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rameziophobia

Copy link
Copy Markdown
Collaborator Author

@claude review this PR

claude added 4 commits April 23, 2026 10:00
…ct shape

Updates combineStatus precedence to
error > regression > visual_change > a11y_violation > improvement > no_difference
per AXE_A11Y_REQUIREMENTS.md §3.2.
Adds:
- compare/engine-bridge/axe.ts thin wrapper around shaka-accessibility runAxe
- compare/harvest/axe.ts projects AxeRunArtifact into CategoryResult,
  truncates html to 500 chars and failureSummary to 2000 chars per
  AXE_A11Y_REQUIREMENTS.md §4.2 (on-disk artifact keeps originals)
- 'axe' in DEFAULT_CATEGORIES and VALID_CATEGORIES
- summarizeFailures() includes a11y violation counter
- axe in abtests.config.ts schema (re-exports AxeGlobalConfigSchema)
- --skip-engines already re-harvests axe-report.json (no new code path)
- AxeSlot.tsx renders one card per viewport with clean/violation pills,
  collapsible rule rows sorted by impact, per-node target breadcrumbs
  (including iframe/shadow descents), and a link to axe's helpUrl.
- CategorySlot hides the a11y slot entirely when options.axe.skip is true
  (requirement 3.10).
- App.tsx + StatusFilter + labels.ts pick up the new a11y_violation
  status so the filter bar, section headers, and grouping all flow
  through without further wiring.
- TestCard emits an A11Y pill with top rule IDs (noisiest first, +N more
  fallback) mirroring perf's REGRESSED pattern.
- styles.css adds a distinct magenta --a11y_violation token so the pill
  and card border-left read separately from the indigo --error purple.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants