Testing Framwork #17
@@ -1,5 +1,5 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { injectAxe, checkA11y } from "@axe-core/playwright";
|
||||
import { AxeBuilder } from "@axe-core/playwright";
|
||||
|
||||
test.describe("Accessibility Testing", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
|
||||
+9
-7
@@ -1,10 +1,12 @@
|
||||
import { injectAxe, checkA11y } from "@axe-core/playwright";
|
||||
import { AxeBuilder } from "@axe-core/playwright";
|
||||
|
||||
export async function runA11y(page, options = {}) {
|
||||
await injectAxe(page);
|
||||
await checkA11y(page, undefined, {
|
||||
detailedReport: true,
|
||||
detailedReportOptions: { html: true },
|
||||
...options,
|
||||
});
|
||||
const results = await new AxeBuilder({ page })
|
||||
.withTags(['wcag2a', 'wcag2aa'])
|
||||
.analyze();
|
||||
|
||||
if (results.violations.length > 0) {
|
||||
console.log('Accessibility violations found:', results.violations);
|
||||
throw new Error(`Found ${results.violations.length} accessibility violations`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user