Skip to content

Commit

Permalink
fix: a11y issues fixes (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyzyl-ool authored May 15, 2024
1 parent 0b005ab commit 4649a40
Show file tree
Hide file tree
Showing 32 changed files with 2,692 additions and 181 deletions.
1 change: 1 addition & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const config: StorybookConfig = {
{name: '@storybook/addon-essentials', options: {backgrounds: false}},
'./theme-addon/register.tsx',
'@storybook/addon-webpack5-compiler-babel',
'@storybook/addon-a11y',
],

webpackFinal: (storybookBaseConfig) => {
Expand Down
33 changes: 33 additions & 0 deletions .storybook/test-runner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type {TestRunnerConfig} from '@storybook/test-runner';
import {getStoryContext} from '@storybook/test-runner';
import {checkA11y, configureAxe, injectAxe} 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, context) {
// Get the entire context of a story, including parameters, args, argTypes, etc.
const storyContext = await getStoryContext(page, context);

// Apply story-level a11y rules
await configureAxe(page, {
rules: storyContext.parameters?.a11y?.config?.rules,
reporter: 'no-passes',
});

await checkA11y(page, '#storybook-root', {
verbose: false,
detailedReport: true,
detailedReportOptions: {
html: true,
},
});
},
};

export default config;
Loading

0 comments on commit 4649a40

Please sign in to comment.