diff --git a/README.md b/README.md index 3b3fcd5c..f003660e 100644 --- a/README.md +++ b/README.md @@ -355,6 +355,20 @@ module.exports = { }; ``` +When running with `--stories-json`, tests get generated in a temporary folder and snapshots get stored alongside. You will need to `--eject` and configure a custom [`snapshotResolver`](https://jestjs.io/docs/configuration#snapshotresolver-string) to store them elsewhere, e.g. in your working directory: + +```js +const path = require('path'); + +module.exports = { + resolveSnapshotPath: (testPath, snapshotExtension) => + path.join(process.cwd(), '__snapshots__', path.basename(testPath) + snapshotExtension), + resolveTestPath: (snapshotFilePath, snapshotExtension) => + path.join(process.env.TEST_ROOT, path.basename(snapshotFilePath, snapshotExtension)), + testPathForConsistencyCheck: path.join(process.env.TEST_ROOT, 'example.test.js'), +}; +``` + ### Image snapshot recipe Here's a slightly different recipe for image snapshot testing: