-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from code0-tech/storybook-tests
Add storybook tests
- Loading branch information
Showing
8 changed files
with
10,152 additions
and
5,144 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
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
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,39 @@ | ||
import type { TestRunnerConfig } from '@storybook/test-runner'; | ||
import { getStoryContext } from '@storybook/test-runner' | ||
import { injectAxe, checkA11y, configureAxe } from 'axe-playwright'; | ||
|
||
const prepareA11y = async (page) => await injectAxe(page); | ||
|
||
const executeA11y = async (page, context) => { | ||
// Get the entire context of a story, including parameters, args, argTypes, etc. | ||
const storyContext = await getStoryContext(page, context); | ||
|
||
// Do not run a11y tests on disabled stories. | ||
if (storyContext.parameters?.a11y?.disable) { | ||
return; | ||
} | ||
|
||
// Apply story-level a11y rules | ||
await configureAxe(page, { | ||
rules: storyContext.parameters?.a11y?.config?.rules, | ||
}); | ||
|
||
await checkA11y(page, '#storybook-root', { | ||
detailedReport: true, | ||
detailedReportOptions: { | ||
html: true, | ||
}, | ||
verbose: false, | ||
}); | ||
} | ||
|
||
const config: TestRunnerConfig = { | ||
async preVisit(page) { | ||
await prepareA11y(page); | ||
}, | ||
async postVisit(page, context) { | ||
await executeA11y(page, context); | ||
}, | ||
}; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nodejs 20.9.0 |
Oops, something went wrong.