Storybook ❤️ Testing Library

Reuse stories in unit tests

Varun Vachhar
Storybook
1 min readMay 18, 2021

--

You have to render a component in isolation to test it. But components can be tough to isolate because they’re connected to data, state, hooks and API calls.

Storybook makes it easy to isolate components for development. You can mock providers and API calls. Or use addons to provide data, static assets and theming context.

We’re excited to launch @storybook/testing-react to help you reuse your stories in Testing Library, Jest and Enzyme. All the setup you’ve done in Storybook to isolate the component is reused in tests.

  1. Write test cases once as “stories”.
  2. Use stories to build the component in Storybook
  3. Reuse stories in your unit testing setup.

👉 Continue reading launch post »

Testing-Library is now the go-to tool for testing component interactions. It’s lightweight and provides utilities that mimic real-world usage. Here are a few helpful resources to get you started:

💖 Varun, DX @ Storybook

--

--