mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 07:21:17 +08:00
48 lines
1.1 KiB
Markdown
48 lines
1.1 KiB
Markdown
```js filename=".storybook/test-runner.js" renderer="common" language="js"
|
|
const { injectAxe, checkA11y } = require('axe-playwright');
|
|
|
|
/*
|
|
* See https://storybook.js.org/docs/writing-tests/test-runner#test-hook-api
|
|
* to learn more about the test-runner hooks API.
|
|
*/
|
|
module.exports = {
|
|
async preVisit(page) {
|
|
await injectAxe(page);
|
|
},
|
|
async postVisit(page) {
|
|
await checkA11y(page, '#storybook-root', {
|
|
detailedReport: true,
|
|
detailedReportOptions: {
|
|
html: true,
|
|
},
|
|
});
|
|
},
|
|
};
|
|
```
|
|
|
|
```ts filename=".storybook/test-runner.ts" renderer="common" language="ts"
|
|
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) {
|
|
await checkA11y(page, '#storybook-root', {
|
|
detailedReport: true,
|
|
detailedReportOptions: {
|
|
html: true,
|
|
},
|
|
});
|
|
},
|
|
};
|
|
|
|
export default config;
|
|
```
|
|
|