Skip to content

UI component dev & test: React, Vue, Angular, React Native, Ember & more!

License

Notifications You must be signed in to change notification settings

ki7/storybook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StoryShots CircleCI

Jest Snapshot Testing for React Storybook

StoryShots In Action

With StoryShots, you could use your existing Storybook stories as the input for Jest Snapshot Testing.

Now, we don't ship a CLI tool for storyshots. Check version 2.x for that.

Getting Started

First of all, you need to use the latest version of React Storybook. So, do this:

npm update @kadira/storybook

Then add the following NPM module into your app.

npm i -D storyshots

Configure your app for Jest

Usually, you might already have completed this step. If not, here are some resources for you.

  • If you are using Create React App, it's already configured for Jest. You just need to create a filename with the extension .test.js.
  • Otherwise check this EggHead lesson.

Configure Storyshots

Create a new test file with the name Storyshots.test.js. (Or whatever the name you prefer). Then add following content to it:

import initStoryshots from '@kadira/storyshots';
initStoryshots();

That's all.

Now run your Jest test command. (Usually, npm test.) Then you can see all of your stories are converted as Jest snapshot tests.

Options

configPath

By default Storyshots assume the default config directory path for your project as below:

  • For React Storybook: .storybook
  • For React Native Storybook: storybook

If you are using a different config directory path, you could change it like this:

initStoryshots({
  configPath: '.my-storybook-config-dir'
});

suit

By default, we group stories inside Jest test suit called "StoryShots". You could change it like this:

initStoryshots({
  suit: 'MyStoryShots'
});

About

UI component dev & test: React, Vue, Angular, React Native, Ember & more!

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 56.1%
  • TypeScript 34.4%
  • HTML 4.6%
  • Kotlin 2.8%
  • Shell 0.8%
  • Vue 0.4%
  • Other 0.9%