Files
magnus919_agent-skills/playwright/templates/accessibility.spec.ts
T
Magnus HedemarkGitHubfactory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
ac1beb117d feat(skill): add Playwright skill (E2E testing + scraping + headless browsing) (#264)
Add ONE tool skill for Playwright: SKILL.md covering E2E test authoring,
selector robustness, network interception/mocking, parallel workers, CI
integration, scraping/headless patterns, accessibility snapshot checks, and
headed debugging; scripts/pwrun (agent-first smoke harness with --json,
fixture-tested); templates/ test-suite scaffold; eight dated references; a
schema-valid evals/evals.json (6 cases); a human-facing README; reverse
routing from qa-methodology and frontend-engineering; top-level README index
entry; and regenerated catalogs (llms.txt, marketplace, codex).

Closes #244.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-08-03 17:59:38 -04:00

34 lines
1.2 KiB
TypeScript

import { test, expect } from '@playwright/test';
import AxeBuilder from '@axe-core/playwright';
/**
* Accessibility smoke scaffold.
*
* Requires: npm i -D @axe-core/playwright
*
* - The axe scan catches WCAG violations (contrast, landmarks, ARIA misuse).
* - The aria snapshot is a stable, accessibility-aware assertion: it compares
* the accessibility tree, so it catches structure and label regressions.
*
* When the aria snapshot legitimately changes, run
* `npx playwright test --update-snapshots` ONLY after reviewing the diff.
*/
test.describe('accessibility', () => {
test('home page has no critical or serious axe violations', async ({ page }) => {
await page.goto('/'); // [fill: route]
const results = await new AxeBuilder({ page }).analyze();
const blocking = results.violations.filter(
(violation) => violation.impact === 'critical' || violation.impact === 'serious',
);
expect(blocking).toEqual([]);
});
test('home page matches the aria snapshot', async ({ page }) => {
await page.goto('/');
await expect(page).toMatchAriaSnapshot(`
- heading "[fill: page heading]" [level=1]
- button "[fill: primary action]"
`);
});
});