-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Addon A11y: Create a11y test provider and revamp a11y addon #29643
Conversation
…/unified-a11y-testing
☁️ Nx Cloud ReportCI is running/has finished running commands for commit b20b03b. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution
Sent with 💌 from NxCloud. |
…-testing # Conflicts: # code/addons/test/src/components/TestProviderRender.tsx # code/core/src/manager/components/sidebar/SidebarBottom.tsx
…dboxes Build: Add addon a11y to sandbox tests
…ity and performance
…STORYBOOK environment variable
…n and MethodCall components
… retrieval in component testing spec
@@ -164,7 +208,7 @@ The test runner provides [helper methods](./test-runner.mdx#helpers), allowing a | |||
|
|||
### Disable a11y tests with the test runner | |||
|
|||
Additionally, if you have already [disabled accessibility](#how-to-disable-a11y-tests) tests for any particular story, you can also configure the test runner to avoid testing it as well. For example: | |||
Additionally, if you have already [disabled accessibility](#turn-off-automated-a11y-tests) tests for any particular story, you can also configure the test runner to avoid testing it as well. For example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to set the tag if you already disabled the test with the global.
Closes #
What I did
Summary
This PR introduces significant updates to the
@storybook/addon-a11y
for improved integration with Storybook's component testing feature, powered by Vitest. The enhancements streamline accessibility testing, provide better developer tooling, and address long-standing issues. Key changes include configuration updates, parameter deprecations, and integration with global reporting features.Changelog
New Features
Added a11y addon annotations to .storybook/vitest.setup.ts for automatic setup during upgrades.
TestDiscrepancyMessage
component to highlight CLI-browser testing discrepancies in the UI.Improved sidebar accessibility status reporting.
globals.a11y.manual
to globally control manual execution of accessibility tests.Deprecations
parameters.a11y.manual
in favor ofglobals.a11y.manual
.Bug Fixes
Migration Notes
For Projects Updating to v8.5:
npx storybook@latest upgrade
integrates the a11y addon into component tests..storybook/vitest.setup.ts
:parameters.a11y.manual
usage toglobals.a11y.manual
.Configuring Violation Impact Levels:
Set the warnings parameter for specific stories:
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
Setup
Case 1: Setup in projects where @experimental-addon-test and @addon-a11y are already installed
npx storybook@<canary> upgrade
.storybook/vitest.setup.ts
Case 2: Setup in projects where @experimental-addon-test and @addon-a11y are already installed, but with undetected
.storybook/vitest.setup.ts
file.storybook/vitest.setup.ts
npx storybook@<canary> upgrade
vitest.setup.ts
, since we couldn't detect it automaticallyCase 3: Add
@storybook/experimental-addon-test
in a project whereaddon-a11y
is already set up (Can only be tested in an alpha release, because the add command in canaries does not work):@storybook/experimental-addon-test
if available and all correlated files (.storybook/vitest.setup.ts
, vitest.workspace,...)npx storybook@<canary> upgrade
npx storybook add @storybook/addon-a11y
(if not already available)npx storybook add @storybook/experimental-addon-test
-> It should set up.storybook/vitest.setup.ts
with addon-a11y annotations.Features
Prerequisites
.storybook/vitest.setup.ts
if the auto migrations or postinstall scripts didn't work.Storybook: Accessibility violations should not be reported per default
Accessibility
checkbox is not ticked in the Testing ModuleStorybook: Accessibility violations should be reported as errors
Accessibility
checkbox is ticked in the Testing ModuleAccessibility tests
in the story context menu to get redirected to the Story.a11y
addon tab should automatically open.Tags support - Disable accessibility runs
.storybook/preview.js
file and set the!a11ytest
tagAccessibility
checkbox is ticked in the Testing ModuleTags support - Partially re-enable accessiblity runs
.storybook/preview.js
file and set the!a11ytest
taga11ytest
tagTest discrepancy
Accessibility
checkbox is ticked in the Testing ModuleDocumentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.🦋 Canary release
This pull request has been released as version
0.0.0-pr-29643-sha-dd3f1df2
. Try it out in a new sandbox by runningnpx storybook@0.0.0-pr-29643-sha-dd3f1df2 sandbox
or in an existing project withnpx storybook@0.0.0-pr-29643-sha-dd3f1df2 upgrade
.More information
0.0.0-pr-29643-sha-dd3f1df2
valentin/unified-a11y-testing
dd3f1df2
1733502964
)To request a new release of this pull request, mention the
@storybookjs/core
team.core team members can create a new canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=29643
Greptile Summary
Based on the extensive changes in this pull request, here's a concise summary:
Major revamp of Storybook's accessibility (a11y) addon with improved test integration and reporting capabilities.
experimental_afterEach
for post-test validation incode/core/src/preview-api/modules/store
ReporterAPI
incode/core/src/preview-api/modules/store/reporter-api.ts
for standardized test result reportingcode/addons/a11y/src/components/TestDiscrepancyMessage.tsx
to highlight differences between CLI and browser test resultsparameters.a11y.manual
in favor ofglobals.a11y.manual
for runtime configurationcode/addons/a11y/src/preview.tsx
The changes look well-structured but should be carefully reviewed for error handling and race conditions in the test lifecycle management.
💡 (5/5) You can turn off certain types of comments like style here!