Accessibility assertions for end-to-end tests
Add WCAG auditing to any Playwright test with a single toBeAccessible() matcher — test full pages or scoped locators.
Features
Page and locator support
Assert on an entire page or scope to a specific locator — test a full page or just a navigation region.
Snapshot baselines
Capture known violations as a baseline and only fail on regressions — a ratchet that can only go down.
Clear failure messages
Each violation includes the rule ID, WCAG level, success criterion, and the CSS selector of the offending element.
Same rule engine
Powered by @accesslint/core — 93 WCAG rules, zero dependencies, fast results.
Quick start
npm install --save-dev @accesslint/playwright // example.spec.ts
import { test, expect } from "@playwright/test";
import "@accesslint/playwright";
test("homepage is accessible", async ({ page }) => {
await page.goto("https://example.com");
await expect(page).toBeAccessible();
}); Snapshot baselines
When you have existing violations that can't be fixed immediately, snapshot baselines let you track them without blocking your test suite. The first run captures a baseline; subsequent runs only fail if new violations appear. When violations are fixed, the baseline ratchets down automatically.
test("dashboard has no new violations", async ({ page }) => {
await page.goto("https://example.com/dashboard");
await expect(page).toBeAccessible({ snapshot: "dashboard" });
}); Snapshots are stored in accessibility-snapshots/ and should be committed to version control. Violations are identified by stable Playwright selectors (like getByRole('img')) so snapshots survive class-name and ID churn.
To force-update all snapshots to the current state, run with npx playwright test -u or set ACCESSLINT_UPDATE=1.