Skip to content

chore(storybook): run stories as tests with vitest and a11y checks - #551

Merged
ggdaltoso merged 10 commits into
masterfrom
chore/storybook-tests
Oct 2, 2026
Merged

ggdaltoso merged 10 commits into
masterfrom
chore/storybook-tests

Conversation

@ggdaltoso

@ggdaltoso ggdaltoso commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Runs every story as a test, in a real browser, and adds accessibility checks. Results show up in Storybook itself and run on PRs.

Story tests

  • Vitest goes from 2.1 to 3.2. Vitest 4 needs Vite 6+, which would also change the published build, so it stays for later.
  • @storybook/addon-vitest runs the stories in headless Chromium (Playwright). A story passes when it renders without errors; once stories get play functions, those run too and their steps show up in the Interactions panel, which is back on (hidden on the documentation stories).
  • The config is packages/core/vitest.config.mjs. It has to be a vitest.config inside the package so the test widget in the sidebar can find it, and it extends the core Vite config for vanilla-extract. It also dedupes React: Storybook nests its own React 19, which can't render our React 18 elements.
  • Documentation and showcase stories (All, Contract, GlobalStyle, Icon and Checkbox › All) are left out with tags: ['!test']. That leaves 44 tests.
  • Clippy stays out of the tests (random agent, timers and network requests).
  • Coverage uses istanbul, like the unit tests: the stories alone cover ~77% of the lines in components/.

Accessibility

  • @storybook/addon-a11y adds the Accessibility panel and checks each story when it's tested.
  • It runs in todo mode, so violations are warnings for now: 22 stories have some, mostly fields without a label (in the stories) and Modal without an accessible name (aria-dialog-name). Switching to error once they're fixed makes them fail.

Running them

  • In Storybook: "Run tests" in the sidebar runs everything (and coverage), and a story's "⋯" menu runs just that one.
  • In the terminal: yarn test:storybook (nx target test-storybook).
  • On PRs: nx affected now also runs test-storybook and build-storybook, so a story that breaks the Storybook build shows up before merging, not after. The agents install Chromium through install-commands.

test-storybook is its own target instead of part of test, so the pre-push hook and the publish workflow keep running without a browser.


This PR only has chore and ci commits, so merging it does not trigger a release (confirmed with nx release --dry-run).

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@nx-cloud

nx-cloud Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit fb8e29c

Command Status Duration Result
nx affected -t lint,test,build,test-storybook,b... ✅ Succeeded 1m 25s View ↗
nx-cloud record -- yarn nx format:check ✅ Succeeded 1s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-10-02 19:07:09 UTC

@ggdaltoso

Copy link
Copy Markdown
Member Author

Coverage report from istanbul

File % Stmts % Branch % Funcs % Lines Uncovered Line #s
All files 91.62 79.37 85.51 91.72
Alert 86.66 76.92 75 85.71
Alert.css.ts 100 100 100 100
Alert.tsx 84.61 76.92 75 83.33 38-39
Avatar 100 100 100 100
Avatar.css.ts 100 100 100 100
Avatar.tsx 100 100 100 100
Button 100 100 100 100
Button.css.ts 100 100 100 100
Button.tsx 100 100 100 100
Checkbox 100 100 100 100
Checkbox.css.ts 100 100 100 100
Checkbox.tsx 100 100 100 100
Dropdown 100 66.66 100 100
Dropdown.css.ts 100 100 100 100
Dropdown.tsx 100 66.66 100 100 22
Fieldset 100 100 100 100
Fieldset.css.ts 100 100 100 100
Fieldset.tsx 100 100 100 100
Frame 100 100 100 100
Frame.css.ts 100 100 100 100
Frame.tsx 100 100 100 100
Input 100 100 100 100
Input.css.ts 100 100 100 100
Input.tsx 100 100 100 100
List 100 0 100 100
List.css.ts 100 100 100 100
List.tsx 100 100 100 100
ListDivider.tsx 100 100 100 100
ListItem.tsx 100 0 100 100 41
Modal 92.98 83.33 84.21 92.98
Modal.css.ts 100 100 100 100
Modal.tsx 92.45 83.33 84.21 92.45 134,173-174,186
ProgressBar 100 0 100 100
...essBar.css.ts 100 100 100 100
ProgressBar.tsx 100 0 100 100 18
RadioButton 100 100 100 100
...Button.css.ts 100 100 100 100
RadioButton.tsx 100 100 100 100
Range 100 100 100 100
Range.css.ts 100 100 100 100
Range.tsx 100 100 100 100
Tabs 93.33 80 100 93.33
Tab.tsx 100 100 100 100
Tabs.css.ts 100 100 100 100
Tabs.tsx 90.9 80 100 90.9 45
TaskBar 83.6 66.66 90 83.05
Clock.tsx 100 100 100 100
TaskBar.css.ts 100 100 100 100
TaskBar.tsx 77.27 57.14 85.71 76.74 ...,44,50,125-130
WindowButton.tsx 100 100 100 100
TextArea 100 100 100 100
TextArea.tsx 100 100 100 100
TitleBar 100 83.33 100 100
TitleBar.css.ts 100 100 100 100
TitleBar.tsx 100 83.33 100 100 97
Tooltip 89.47 100 80 89.47
Tooltip.css.ts 100 100 100 100
Tooltip.tsx 88.23 100 80 88.23 56-57
Tree 72.22 64 50 72.22
Node.tsx 64.28 68.18 41.66 64.28 97-99,109,146-160
Tree.css.ts 100 100 100 100
Tree.tsx 100 33.33 100 100 26-29
Video 91.02 90 72 92.1
Video.css.ts 100 100 100 100
Video.tsx 89.7 90 72 90.9 94-109
Video/buttons 100 100 100 100
Fullscreen.tsx 100 100 100 100
Pause.tsx 100 100 100 100
Play.tsx 100 100 100 100
Stop.tsx 100 100 100 100
shared 98.07 91.66 100 98
emitter.ts 91.66 83.33 100 91.66 25
...controller.ts 100 100 100 100
modal-types.ts 100 100 100 100
use-modal.ts 100 100 100 100
shared/test 100 100 100 100
utils.ts 100 100 100 100

@ggdaltoso
ggdaltoso marked this pull request as ready for review October 2, 2026 19:34
@ggdaltoso
ggdaltoso merged commit 1b94d9f into master Oct 2, 2026
9 checks passed
@ggdaltoso
ggdaltoso deleted the chore/storybook-tests branch October 2, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant