storybook/docs/snippets/common/storybook-test-runner-a11y-config.ts.mdx
Norbert de Langen 36702ebe0c
I changed #root => #storybook-root
I changed #docs-root => #storybook-docs
2022-08-02 11:18:33 +02:00

27 lines
619 B
Plaintext

```ts
// .storybook/test-runner.ts
import { injectAxe, checkA11y } from 'axe-playwright';
import type { TestRunnerConfig } from '@storybook/test-runner';
/*
* See https://storybook.js.org/docs/7.0/react/writing-tests/test-runner#test-hook-api-experimental
* to learn more about the test-runner hooks API.
*/
const a11yConfig: TestRunnerConfig = {
async preRender(page) {
await injectAxe(page);
},
async postRender(page) {
await checkA11y(page, '#storybook-root', {
detailedReport: true,
detailedReportOptions: {
html: true,
},
});
},
};
module.exports = a11yConfig;
```