Skip to content

Commit

Permalink
Update Storyshots README w/ instructions per loading method (#8465)
Browse files Browse the repository at this point in the history
Update Storyshots README w/ instructions per loading method
  • Loading branch information
shilman committed Oct 18, 2019
2 parents 4c4f5af + 79846e1 commit 667a9e0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion addons/storyshots/storyshots-core/README.md
Expand Up @@ -33,7 +33,9 @@ If you still need to configure jest you can use the resources mentioned below:

### Configure Jest to work with Webpack's [require.context()](https://webpack.js.org/guides/dependency-management/#require-context)

Sometimes it's useful to configure Storybook with Webpack's require.context feature:
Sometimes it's useful to configure Storybook with Webpack's require.context feature. You could be loading stories [one of two ways](https://storybook.js.org/docs/basics/writing-stories/#loading-stories).

1) If you're using the `storiesOf` API, you can integrate it this way:

```js
import { configure } from '@storybook/react';
Expand All @@ -47,6 +49,16 @@ function loadStories() {
configure(loadStories, module);
```

2) If you're using Component Story Format (CSF), you'll integrate it like so:

```js
import { configure } from '@storybook/react';

const req = require.context('../stories', true, /\.stories\.js$/); // <- import all the stories at once

configure(req, module);
```

The problem here is that it will work only during the build with webpack,
other tools may lack this feature. Since Storyshot is running under Jest,
we need to polyfill this functionality to work with Jest. The easiest
Expand Down

1 comment on commit 667a9e0

@vercel
Copy link

@vercel vercel bot commented on 667a9e0 Oct 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.