-
Notifications
You must be signed in to change notification settings - Fork 3
Add Storybook test runner for accessibility testing #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c59fdb1
Add Storybook test runner.
e08379c
Add GitHub Actions workflow for Storybook test runner.
ed8b5cf
Update storybook_test.yaml name.
3ebbfe4
Add test:storybook-ci command.
0c1ac99
Add 'playwright install'.
8d30f6e
Add 'playwright install-deps'.
a9d24a8
Update playwright install command.
320d5e2
Update playwright install command.
73e0c69
Update axe-playwright config.
bdc2d21
Remove ignored rules.
95d2dff
Add license header.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | ||
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | ||
|
|
||
| name: Storybook Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "**" ] | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| matrix: | ||
| node-version: [22.x] | ||
| # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: 'npm' | ||
| - run: npm ci | ||
| #- run: npm run build --if-present | ||
| - run: npm run test:storybook-ci | ||
| continue-on-error: true # Not enforced for now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /* Copyright (c) Fortanix, Inc. | ||
| |* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of | ||
| |* the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| import { type TestRunnerConfig, getStoryContext } from '@storybook/test-runner'; | ||
| import { injectAxe, configureAxe, 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, 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, | ||
| }); | ||
|
|
||
| const element = storyContext.parameters?.a11y?.element ?? '#storybook-root'; | ||
| await checkA11y(page, element, { | ||
| detailedReport: true, | ||
| detailedReportOptions: { | ||
| html: true, | ||
| }, | ||
| }); | ||
| }, | ||
| }; | ||
|
|
||
| export default config; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.