mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 11:11:53 +08:00
20 lines
719 B
Plaintext
20 lines
719 B
Plaintext
```js
|
|
// ./snapshot-resolver.js
|
|
import path from 'path';
|
|
|
|
export default {
|
|
resolveSnapshotPath: (testPath) => {
|
|
const fileName = path.basename(testPath);
|
|
const fileNameWithoutExtension = fileName.replace(/\.[^/.]+$/, '');
|
|
// Defines the file extension for the snapshot file
|
|
const modifiedFileName = `${fileNameWithoutExtension}.snap`;
|
|
|
|
// Configure Jest to generate snapshot files using the following convention (./src/test/__snapshots__/Button.stories.snap)
|
|
return path.join('./src/test/__snapshots__', modifiedFileName);
|
|
},
|
|
resolveTestPath: (snapshotFilePath, snapshotExtension) =>
|
|
path.basename(snapshotFilePath, snapshotExtension),
|
|
testPathForConsistencyCheck: 'example',
|
|
};
|
|
```
|