Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add storyshots migration guides #380

Merged
merged 9 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# `@storybook/addon-storyshots` Migration Guide

Storyshots (`@storybook/addon-storyshots`) was Storybook's original testing solution. It providing automatic snapshot testing and rich configurability. However, it was fundamentally incompatible with Storybook 7's high-performance [on-demand architecture](https://storybook.js.org/blog/storybook-on-demand-architecture/), and suffered from other limitations. In response, we created [Storybook test-runner](https://storybook.js.org/docs/react/writing-tests/test-runner) as a successor in 2021.

Now that we are finally removing the old architecture in Storybook 8, Storyshots will become incompatible. If you're using Storyshots and you want to upgrade to Storybook 8, you'll need to migrate to something else. This guide will aid you in that process.

Below you will find serveral options to migrate:

1. **Storybook test-runner** is Storybook's recommended open source testing tool.
2. **Portable stories** is an alternative approach that might be an easier migration from Storyshots, and is also supported by the core team.
3. **Chromatic** is a great option if you are looking for a fully hosted service, and built by Storybook maintainers.

You can decide for yourself which path to choose, by following the guides below.

## Option 1 - Storybook test-runner

Storybook test-runner turns all of your stories into executable tests, powered by [Jest](https://jestjs.io/) and [Playwright](https://playwright.dev/). It's powerful and provides multi-browser testing, and you can achieve many things with it such as smoke testing, DOM snapshot testing, Accessibility testing, Visual Regression testing and more.

The test-runner supports any official Storybook framework and is compatible with community frameworks (support may vary). If you use Storybook for React Native, you can use the test-runner as long as you set up the [react-native-web addon](https://storybook.js.org/addons/@storybook/addon-react-native-web/) in your project.

Follow the [migration steps to test-runner here](./MIGRATION.test-runner.md).

## Option 2 - Portable stories

Portable stories are utilities from Storybook that assist in converting stories from a story file into renderable elements that can be reused in your Node tests with JSDOM with tools like [Jest](https://jestjs.io/) or [Vitest](https://vitest.dev/). This is the closest you will get from storyshots, but with the caveat that you will face similar challenges, given that the tests still run in Node. If you use storyshots extensively with complex mocking mechanisms and snapshot serializers, this migration will be the simplest option.

This option is currently only available for React, React Native (without the [react-native-web addon](https://storybook.js.org/addons/@storybook/addon-react-native-web/)) or Vue3. However, we plan to support more renderers in the future.

Follow the [migration steps to portable stories here](./MIGRATION.portable-stories.md).

## Option 3 - Chromatic

[Chromatic](https://www.chromatic.com/) is a cloud service for taking visual snapshots of your stories, developed by the maintainers of Storybook. It is easy to set up and configure, and has a free plan. We recommend it if you are looking for a high quality hosted testing solution. See the [Chromatic site](https://www.chromatic.com/) for setup instructions.
Loading
Loading