-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
28 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
import AxeBuilder from "@axe-core/playwright"; | ||
import { test, expect } from "@playwright/test"; | ||
import { test, expect } from "./fixtures.js"; | ||
|
||
test("can be visited", async ({ page }) => { | ||
await page.goto("/nested/about/path"); | ||
|
||
await expect(page.getByRole("heading", { level: 1 })).toHaveText("About"); | ||
}); | ||
|
||
test("meets a11y requirements", async ({ page }) => { | ||
test("meets a11y requirements", async ({ axe, page }) => { | ||
await page.goto("/nested/about/path"); | ||
const axeBuilder = new AxeBuilder({ page }).withTags("wcag2a"); | ||
const { violations } = await axeBuilder.analyze(); | ||
|
||
const { violations } = await axe.analyze(); | ||
expect(violations).toHaveLength(0); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import AxeBuilder from "@axe-core/playwright"; | ||
import { test as base } from "@playwright/test"; | ||
|
||
/** | ||
* @typedef {import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions} T | ||
* @typedef {import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions} W | ||
*/ | ||
|
||
/** | ||
* @type {import("@playwright/test").TestType<T & { a11yTags: string[]; axe: AxeBuilder }, W>} | ||
*/ | ||
export const test = base.extend({ | ||
a11yTags: [["wcag2a"], { option: true }], | ||
axe: async ({ a11yTags, page }, use) => { | ||
const axe = new AxeBuilder({ page }).withTags(a11yTags); | ||
await use(axe); | ||
}, | ||
}); | ||
|
||
export { expect } from "@playwright/test"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters