Testing Framwork #17
@@ -1,5 +1,5 @@
|
|||||||
import { test, expect } from "@playwright/test";
|
import { test, expect } from "@playwright/test";
|
||||||
import { injectAxe, checkA11y } from "@axe-core/playwright";
|
import { AxeBuilder } from "@axe-core/playwright";
|
||||||
|
|
||||||
test.describe("Accessibility Testing", () => {
|
test.describe("Accessibility Testing", () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
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 = {}) {
|
export async function runA11y(page, options = {}) {
|
||||||
await injectAxe(page);
|
const results = await new AxeBuilder({ page })
|
||||||
await checkA11y(page, undefined, {
|
.withTags(['wcag2a', 'wcag2aa'])
|
||||||
detailedReport: true,
|
.analyze();
|
||||||
detailedReportOptions: { html: true },
|
|
||||||
...options,
|
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