It's easy to overlook that your component stories stopped working after changes to the component source. If we're not reusing our stories in unit tests and thus ensure they still work on CI in every Pull Request, we need to remember to check them during code review.
When you're hotfixing a production bug you have more serious concerns than not breaking the docs. That's understandable. Every app I worked on that used Storybook eventually had some broken stories. Fixing them lands at the bottom of the backlog; they're just some component examples and those components work on production now! You're going to do it only if you actually need those stories.
Could we write a simple test to ensure that all our stories render without crashing, and more than that, they actually render the component they're meant to render?
We could even consider snapshot testing with
@storybook/addon-storyshots
,
but
-
I'm not a huge fan of failing the test when CSS gets changed. (unless you're building a CSS-in-JS library). We want to write this test to lower the cost of maintenance and know earlier when something breaks.
-
I'm actually not using Storybook itself in the app I'm working on, just PreviewJS with Component Story Format.
⬇ source below ⬇