Recipe
axe-core Automated a11y Tests
Catch 57% of WCAG violations before they reach production with zero-config CI integration.
Why axe-core
Deque's axe-core is the engine powering Lighthouse, Chrome DevTools, and Microsoft Accessibility Insights. It runs in Node, browsers, and any CI runner — no browser extension required.
Install
npm i -D @axe-core/playwrightPlaywright fixture
import { test as base } from '@playwright/test';
import AxeBuilder from '@axe-core/playwright';
export const test = base.extend<{
axe: AxeBuilder;
}>({
axe: async ({ page }, use) => {
await use(new AxeBuilder({ page }));
},
});Write a test
test('homepage has no detectable a11y violations', async ({
page,
axe,
}) => {
await page.goto('/');
const results = await axe.analyze();
expect(results.violations).toEqual([]);
});CI integration
Run alongside your existing Playwright suite. Fail the build on violations. Tag critical paths with axeBuilder.include('#main-content') to scope scans and reduce noise.
Rules reference
color-contrastWCAG 1.4.3
button-nameWCAG 4.1.2
image-altWCAG 1.1.1
link-nameWCAG 2.4.4