@chanzuckerberg/story-utils

Utilities for using Storybook stories in non-Storybook environments. For example, using stories in Jest tests.

Usage no npm install needed!

<script type="module">
  import chanzuckerbergStoryUtils from 'https://cdn.skypack.dev/@chanzuckerberg/story-utils';
</script>

README

story-utils

Utilities for using Storybook stories in non-Storybook environments. For example, using stories in Jest tests.

Installation

Install @chanzuckerberg/story-utils with your favorite package manager. With yarn, that would look like

yarn add --dev @chanzuckerberg/story-utils

Utilities

generateSnapshots

Auto generates snapshots for stories


import * as snapshotTestStoryFile from "./MyButton.stories";
import { generateSnapshots } from "@chanzuckerberg/story-utils";

describe("My button", () => {
  generateSnapshots(snapshotTestStoryFile);
});

If you want to skip generating snapshots for a story:

SomeStory.parameters = {
  snapshot: {
    skip: true,
  },
};