4.0.8 • Published 1 year ago

@chanzuckerberg/story-utils v4.0.8

Weekly downloads
462
License
-
Repository
github
Last release
1 year ago

story-utils

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

Requirements

  • Storybook 7 or 8
    • If you're using Storybook Storybook 6, use story-utils@v3

Installation

Install @chanzuckerberg/story-utils with your favorite package manager.

npm install --save-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,
  },
};

wait(ms: number) => void

A utility function that can be used to wait for when testing in react

import { wait } from "@chanzuckerberg/story-utils";

test('example', async () => {
  renderSomething()
  await wait();

  // add expect matchers after
})
4.0.8

1 year ago

3.0.14

2 years ago

4.0.0

2 years ago

3.0.13

2 years ago

3.0.12

2 years ago

3.0.11

3 years ago

3.0.9

3 years ago

3.0.10

3 years ago

3.0.9-alpha.0

3 years ago

3.0.8

3 years ago

3.0.7

3 years ago

3.0.6

3 years ago

3.0.5

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

3.0.0-alpha.16

4 years ago

3.0.0-alpha.17

4 years ago

2.1.0

4 years ago

2.0.1-alpha.12

4 years ago

2.0.0

4 years ago

1.2.1

4 years ago

1.2.0

5 years ago

1.1.0-alpha.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago

0.1.0-alpha.1

5 years ago