Framework:

Unit testing with Storybook

Unit tests are useful for verifying functional aspects of components. They verify that the output of a component remains the same given a fixed input.

Unit testing with a component

Thanks to the CSF format, your stories are reusable in unit testing tools. Each named export is β€œrenderable” without depending on Storybook. That means your testing framework will also be able to render that story.

Here is an example of how you can use it in a testing library:

Unit tests can be brittle and expensive to maintain for every component. We recommend combining unit tests with other testing methods like visual regression testing for comprehensive coverage with less maintenance work.