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 22, 2019
1 parent 98bd8bf commit 39320e3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion addons/storyshots/storyshots-core/README.md
Original file line number Diff line number Diff line change
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

0 comments on commit 39320e3

Please sign in to comment.