-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add test-runner and Playwright to generate HTML a11y reports
- Loading branch information
Showing
4 changed files
with
1,350 additions
and
19 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { TestRunnerConfig } from "@storybook/test-runner"; | ||
import { injectAxe, checkA11y } from "axe-playwright"; | ||
|
||
/* | ||
* See https://storybook.js.org/docs/writing-tests/test-runner#test-hook-api | ||
* to learn more about the test-runner hooks API. | ||
*/ | ||
const config: TestRunnerConfig = { | ||
async preVisit(page) { | ||
await injectAxe(page); | ||
}, | ||
async postVisit(page, story) { | ||
const fileName = story.name.replace(/\s+/g, ""); | ||
await checkA11y( | ||
page, | ||
".story-content", | ||
{ | ||
detailedReport: true, | ||
detailedReportOptions: { | ||
html: true, | ||
}, | ||
}, | ||
undefined, | ||
"html", | ||
{ | ||
reportFileName: `${fileName}-result.html`, | ||
}, | ||
); | ||
}, | ||
}; | ||
|
||
export default config; |
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
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,21 @@ | ||
import { defineConfig, devices } from "@playwright/test"; | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
projects: [ | ||
{ | ||
name: "Desktop Chrome", | ||
use: devices["Desktop Chrome"], | ||
}, | ||
{ | ||
name: "Desktop Firefox", | ||
use: devices["Desktop Firefox"], | ||
}, | ||
{ | ||
name: "Mobile Chrome", | ||
use: devices["Pixel 5"], | ||
}, | ||
], | ||
}); |
Oops, something went wrong.