Skip to content

Commit 4649a40

Browse files
authored
fix: a11y issues fixes (#189)
1 parent 0b005ab commit 4649a40

File tree

32 files changed

+2692
-181
lines changed

32 files changed

+2692
-181
lines changed

.storybook/main.ts

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const config: StorybookConfig = {
1515
{name: '@storybook/addon-essentials', options: {backgrounds: false}},
1616
'./theme-addon/register.tsx',
1717
'@storybook/addon-webpack5-compiler-babel',
18+
'@storybook/addon-a11y',
1819
],
1920

2021
webpackFinal: (storybookBaseConfig) => {

.storybook/test-runner.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type {TestRunnerConfig} from '@storybook/test-runner';
2+
import {getStoryContext} from '@storybook/test-runner';
3+
import {checkA11y, configureAxe, injectAxe} from 'axe-playwright';
4+
5+
/*
6+
* See https://storybook.js.org/docs/writing-tests/test-runner#test-hook-api
7+
* to learn more about the test-runner hooks API.
8+
*/
9+
const config: TestRunnerConfig = {
10+
async preVisit(page) {
11+
await injectAxe(page);
12+
},
13+
async postVisit(page, context) {
14+
// Get the entire context of a story, including parameters, args, argTypes, etc.
15+
const storyContext = await getStoryContext(page, context);
16+
17+
// Apply story-level a11y rules
18+
await configureAxe(page, {
19+
rules: storyContext.parameters?.a11y?.config?.rules,
20+
reporter: 'no-passes',
21+
});
22+
23+
await checkA11y(page, '#storybook-root', {
24+
verbose: false,
25+
detailedReport: true,
26+
detailedReportOptions: {
27+
html: true,
28+
},
29+
});
30+
},
31+
};
32+
33+
export default config;

0 commit comments

Comments
 (0)