mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-03 05:04:51 +08:00
1020 B
1020 B
title |
---|
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.
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:
<CodeSnippets paths={[ 'react/button-test.js.mdx', ]} />
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.