mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 11:11:53 +08:00
33 lines
907 B
Plaintext
33 lines
907 B
Plaintext
```js
|
|
// storybook.test.js|ts
|
|
|
|
// 👇 Augment expect with jest-specific-snapshot
|
|
import 'jest-specific-snapshot';
|
|
|
|
// ...Code omitted for brevity
|
|
|
|
describe(options.suite, () => {
|
|
//👇 Add storyDir in the arguments list
|
|
getAllStoryFiles().forEach(({ filePath, storyFile, storyDir }) => {
|
|
// ...Previously existing code
|
|
describe(title, () => {
|
|
// ...Previously existing code
|
|
stories.forEach(({ name, story }) => {
|
|
// ...Previously existing code
|
|
testFn(name, async () => {
|
|
// ...Previously existing code
|
|
|
|
//👇 Define the path to save the snapshot to:
|
|
const snapshotPath = path.join(
|
|
storyDir,
|
|
options.snapshotsDirName,
|
|
`${componentName}${options.snapshotExtension}`,
|
|
);
|
|
expect(mounted.container).toMatchSpecificSnapshot(snapshotPath);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
```
|