Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit e633c19

Browse files
authored
test: storybook accessibility testing using axe playwright (#222)
1 parent 43d999d commit e633c19

File tree

7 files changed

+13104
-9696
lines changed

7 files changed

+13104
-9696
lines changed

.github/workflows/ci.yml

+6
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@ jobs:
2424
with:
2525
node-version: '20.x'
2626
registry-url: 'https://registry.npmjs.org'
27+
- name: Install Playwright
28+
run: npx playwright install --with-deps
2729
- name: Build and test
2830
run: |
2931
npm ci
3032
npm run format:check
3133
npm run test
3234
npm run build:package
3335
npm run build:dist
36+
npm run storybook:build
37+
- name: Serve Storybook and run accessibility tests
38+
run: |
39+
npm run test:storybook
3440
- name: Create zip artifact
3541
if: github.ref == 'refs/heads/main'
3642
run: |

.storybook/test-runner.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { injectAxe, checkA11y } from 'axe-playwright';
2+
3+
/*
4+
* See https://storybook.js.org/docs/writing-tests/test-runner#test-hook-api
5+
* to learn more about the test-runner hooks API.
6+
*/
7+
const config = {
8+
async preVisit(page) {
9+
await injectAxe(page);
10+
},
11+
async postVisit(page) {
12+
await checkA11y(page, '#storybook-root', {
13+
detailedReport: true,
14+
detailedReportOptions: {
15+
html: true,
16+
},
17+
});
18+
},
19+
};
20+
21+
export default config;

0 commit comments

Comments
 (0)