-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
A11y error: The accessibility scan encountered an error. {} #12622
Comments
I've found the source of the error but still, I can't understand why this code causes an error.
As soon as I remove or rename |
I agree, we should probably give a better error message here. Any takers? |
Automention: Hey @Armanio @CodeByAlex @jsomsanith, you've been tagged! Can you give a hand here? |
@shilman I would want to give it a try. I've been using storybook for quite some time. I would also be good for me to know how storybook works under the hood and give something back to it. |
@imshubhamsingh Thank you for wanting to make Storybook better! 🙏 Please check out CONTRIBUTING.md to get started and feel free to ask questions in our Discord. |
@shilman I'll debug this and hopefully share information soon on this. Thanks for info ✌️. |
@HosseinRashno can you share a repo which reproduces this error. I created storybook for lit-element but didn't face such issue. |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Hi 👋 |
With Vite builder: Didn't work on 6.4.18 with old repository "storybook-builder-vite" (Build error) It worked with the update to "@storybook/builder-vite" and version 6.4.19 Again it stopped working with version 6.4.20 and higher. No compilation errors; but it shows the aforementioned error: The accessibility scan encountered an error. {} |
Hey @Stunext thank you for your a11y-bug repo.
The code in axe-core is something like
With both bundlers we have the default in the dynamic import module containing all the functions, but with webpack, we also have access to the functions directly. This makes sense as, in theory, we can statically import default containing all the functions, of destructure it to import the named functions. But I'll provide a fix to be compatible with both, as both have access to the module default. |
I believe the difference boils down to how vite vs webpack treat compatibility between commonjs and esm. Technically, according to the spec, All that said, I think the most correct thing to do here, would be to use the module |
Issue: #12622 `Axe-core` exposes a commonjs module equivalent to ```javascript const axe = {}; // a bunch of code adding functions in axe object module.exports = axe; ``` Storybook with builder-vite wraps axe-core dynamic import and ends up with a module containing only default export. ```javascript // axe-core module with vite { default: { run, reset, ... } } ``` Webpack has another behavior, and ends up with a module containing default and all the named export function. ```javascript // axe-core module with vite { default: { run, reset, ... }, run, reset, ... } ``` But `addon-a11y` imports `axe-core` and use it directly with `axe.run()` for example, consuming the named exports. For storybook with vite, it fails as `axe.run()` doesn't exist, whereas `axe.default.run()` exists. ## What I did In `addon-a11y`, consume axe default export as it is always available. ## How to test - [ ] Is this testable with Jest or Chromatic screenshots? - [ ] Does this need a new example in the kitchen sink apps? - [ ] Does this need an update to the documentation? If your answer is yes to any of these, please make sure to include it in your PR. <!-- Everybody: Please submit all PRs to the `next` branch unless they are specific to the current release. Storybook maintainers cherry-pick bug and documentation fixes into the `master` branch as part of the release process, so you shouldn't need to worry about this. For additional guidance: https://storybook.js.org/docs/react/contribute/how-to-contribute Maintainers: Please tag your pull request with at least one of the following: `["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]` -->
@IanVS Thanks for the explanation and the PR review :) |
@jsomsanith has this fix been released? if so, which release? I am experiencing this issue after switching over to storybook for vite. Any input greatly appreciated! |
@joshrobertsv2 it was first included in v6.5.0-beta.0. If you're having an issue after that version, feel free to open an issue on the vite-builder repo, ideally with a reproduction, and we can take a look. |
Thanks @IanVS ! |
FYI for anyone else who ends up here, I was receiving this on -"@storybook/addon-a11y": "^6.5.13",
+"@storybook/addon-a11y": "^7.0.0-alpha.40",
"@storybook/addon-essentials": "^7.0.0-alpha.40",
"@storybook/addon-interactions": "^7.0.0-alpha.40", |
@taitems note that you can also use |
@IanVS - Is your helpful note still applicable with current and RC, and in future, v7 ? I would find it immensely helpful if a knowledgeable tidbit like this was surfaced a bit more clearly in the main documentation, as I have ended up here specifically, multiple times. Also, it is quite possible I should either decrease or increase intake of caffeine. :: tossup :: 😵💫 |
@weo3dev what are you referring to? As far as I know, |
Oh - apologies for not being clear - using the specific callout of 'sb@next' is really great, and works! Was just wondering if that is a hook, for lack of a better term in my brain, that we will be able to use moving forward to keep add ons up to date more easily. |
@IanVS I'm aware of this, and this is something that I'm going to bring over to the team (Storybook & DX) so that we provide a good experience for it. As most addons snippets mention only the package managers (e.g., |
@weo3dev you can continue to use it, but once 7.0 becomes "stable", then |
Thank you so much for the clarification! Y'all rock. Thank you so much. |
Describe the bug
I've followed this tutorial to add "storybook-addon-a11y" to my project. Now it shows "Accessibility" tab in the addons tabs. It works well for most of the stories, but it shows an error for some of them. This is the error:
The error object is empty so I have no idea what's the problem here. I've tried to add a console log in this file to see the error in the console, and the result was this:
TypeError {}
To Reproduce
I've added the a11y addon to my project and the error happened!
Expected behavior
It should not throw an error for no reason, if something is going wrong, it should show a clear error.
Screenshots

System
The text was updated successfully, but these errors were encountered: