Describe the bug
Ref: see this comment in issue 34613
I've managed to setup a working implementation of Vitest a11y testing in my (unsupported) Storybook/HTML repo.
In the comment referenced above, I've had to implement a temporary workaround to enable me to disable a couple of Axe rules that are failing when they should not be - snippet from my .storybook/preview.js:
a11y: {
// 'todo' - show a11y violations in the test UI only
// 'error' - fail CI on a11y violations
// 'off' - skip a11y checks entirely
test: 'error',
context: 'body',
config: {},
options: {
runOnly: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'best-practice', 'wcag22a', 'wcag22aa'],
rules: {
'target-size': { enabled: false },
'region': { enabled: false },
},
},
},
The issues I'm having are two-fold:
- I've had to move my disabled rules from
config.rules into options.rules so they're in the same axe.run() call as runOnly. This points to a bug in the addon where disabled rules from config should be forwarded into the options.rules passed to axe.run() when runOnly is present.
- I should not have to disable either rule:
(a) region should already be ignored in a Storybook context as components are often rendered standalone, not inside landmark regions.
(b) target-size is failing in CLI only for a number of components, but passing from the Storybook UI (as well as passing with 3 different browser devtools a11y checkers - AxeCore, ARC Toolkit, IBM Equal Access).
Furthermore, one of the failing components passes tests with no additional rule overrides in my simple reproduction repo, which only contains 1 story.
Reproduction link
https://github.com/basher/Web-UI-Boilerplate/tree/master
Reproduction steps
npm run test-storybook from the repro link above. 96 tests run. All pass.
- Comment out the 2
rules overrides in .storybook/preview.js, and region / target-size tests fail for a large number of components.
npm run test-storybook from the minimal repo, which only contains 1 story. Tests run. All pass. No rules overrides necessary.
System
Storybook Environment Info:
│
│ System:
│ OS: Windows 10 10.0.19045
│ CPU: (4) x64 Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz
│ Binaries:
│ Node: 22.19.0 - C:\Program Files\nodejs\node.EXE
│ Yarn: 1.22.22 - C:\Users\kev\AppData\Roaming\npm\yarn.CMD
│ npm: 10.9.3 - C:\Program Files\nodejs\npm.CMD <----- active
│ Browsers:
│ Chrome: 147.0.7727.102
│ Edge: Chromium (140.0.3485.94)
│ Firefox: 150.0 - C:\Program Files (x86)\Mozilla Firefox\firefox.exe
│ npmPackages:
│ @storybook/addon-a11y: ^10.3.5 => 10.3.5
│ @storybook/addon-docs: ^10.3.5 => 10.3.5
│ @storybook/addon-vitest: ^10.3.5 => 10.3.5
│ @storybook/html-vite: ^10.3.5 => 10.3.5
│ storybook: ^10.3.5 => 10.3.5
Additional context
No response
Describe the bug
Ref: see this comment in issue 34613
I've managed to setup a working implementation of Vitest a11y testing in my (unsupported) Storybook/HTML repo.
In the comment referenced above, I've had to implement a temporary workaround to enable me to disable a couple of Axe rules that are failing when they should not be - snippet from my
.storybook/preview.js:The issues I'm having are two-fold:
config.rulesintooptions.rulesso they're in the sameaxe.run()call asrunOnly. This points to a bug in the addon where disabled rules fromconfigshould be forwarded into theoptions.rulespassed toaxe.run()whenrunOnlyis present.(a)
regionshould already be ignored in a Storybook context as components are often rendered standalone, not inside landmark regions.(b)
target-sizeis failing in CLI only for a number of components, but passing from the Storybook UI (as well as passing with 3 different browser devtools a11y checkers - AxeCore, ARC Toolkit, IBM Equal Access).Furthermore, one of the failing components passes tests with no additional rule overrides in my simple reproduction repo, which only contains 1 story.
Reproduction link
https://github.com/basher/Web-UI-Boilerplate/tree/master
Reproduction steps
npm run test-storybookfrom the repro link above. 96 tests run. All pass.rulesoverrides in.storybook/preview.js, andregion/target-sizetests fail for a large number of components.npm run test-storybookfrom the minimal repo, which only contains 1 story. Tests run. All pass. Norulesoverrides necessary.System
Additional context
No response