Skip to content

feat(examples): migrate to examples to Storybook test addon#150

Merged
sjwilczynski merged 27 commits intomicrosoft:mainfrom
sjwilczynski:sjwilczy/testAddon
Apr 8, 2025
Merged

feat(examples): migrate to examples to Storybook test addon#150
sjwilczynski merged 27 commits intomicrosoft:mainfrom
sjwilczynski:sjwilczy/testAddon

Conversation

@sjwilczynski
Copy link
Copy Markdown
Contributor

@sjwilczynski sjwilczynski commented Mar 31, 2025

The initial plan for Storybook folks to make stories behave as tests, was using @storybook/test-runner. As useful as it was, the fact that it used jest as orchestrator made things slower than they should be. On top of that the current default for Storybook + React is to use vite instead of webpack just because of perf gains. No surprise then that to make the vite integration even more simplest, they wanted to integrate with vitest, their test runner. Their result of that integration is test addon. Even tough it is marked as experimental, Storybook folks already announced this as future of their testing workflow. Check how nicely it integrates both with command line and UI:

testAddon

You can run your stories as tests both from UI and from command line without any issues with awesome DX provided by vitest which is significantly faster than jest.

1JS is still on Storybook 7 so might be a bit harder to use it like that there but other repos have the benefit of being able to use latest greatest and (looking at you @kerrynf ) I would recommend start to experiment with it there.

This allows us to migrate majority of jest tests directly into Storybook, only left the ones that really verify something in jest environment. Part of this PR is extracted to #151 for easier review

@sjwilczynski sjwilczynski marked this pull request as ready for review April 3, 2025 07:15
@sjwilczynski sjwilczynski enabled auto-merge (squash) April 3, 2025 07:18
@sjwilczynski
Copy link
Copy Markdown
Contributor Author

sjwilczynski commented Apr 8, 2025

Check source maps.

Update: @alloy I checked and they behave fine:
image
Storybook just renders stuff in iframe that's why I didn't find it initially

Copy link
Copy Markdown
Member

@alloy alloy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the request to check if source-maps are working correctly, this looks great!

@sjwilczynski sjwilczynski merged commit f525c82 into microsoft:main Apr 8, 2025
2 checks passed
@sjwilczynski sjwilczynski deleted the sjwilczy/testAddon branch April 8, 2025 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants