accessibility.spec.template.ts•1.07 kB
// Generated by DocuMCP - Accessibility Tests
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
test.describe("Accessibility", () => {
test("should not have WCAG violations", async ({ page }) => {
await page.goto("/");
const results = await new AxeBuilder({ page })
.withTags(["wcag2a", "wcag2aa"])
.analyze();
expect(results.violations).toEqual([]);
});
test("should support keyboard navigation", async ({ page }) => {
await page.goto("/");
await page.keyboard.press("Tab");
const focused = await page.evaluate(() => document.activeElement?.tagName);
expect(["A", "BUTTON", "INPUT"]).toContain(focused);
});
test("images should have alt text", async ({ page }) => {
await page.goto("/");
const images = await page.locator("img").all();
for (const img of images) {
const alt = await img.getAttribute("alt");
const role = await img.getAttribute("role");
if (role !== "presentation") {
expect(alt).toBeTruthy();
}
}
});
});