storybook/docs/snippets/common/storybook-storyshots-custom-directory.js.mdx
Unknown a09f41741b fix:snapshots-testing doc's mdx
・typo
・Delete a comment(doesn't write anything.)
2020-10-23 21:47:18 +09:00

25 lines
728 B
Plaintext

```js
// storybook.test.js
import path from 'path';
import initStoryshots from '@storybook/addon-storyshots';
// the required import from the @storybook/addon-storyshots-puppeteer addon
import { imageSnapshot } from '@storybook/addon-storyshots-puppeteer'
// function to customize the snapshot location
const getMatchOptions = ({ context: { fileName }}) => {
// Generates a custom path based on the file name and the custom directory.
const snapshotPath = path.join(path.dirname(fileName), 'your-custom-directory');
return { customSnapshotsDir: snapshotPath };
}
initStoryshots({
// your own configuration
test: imageSnapshot({
// invoke the function above here
getMatchOptions
})
});
```