forked from PostHog/posthog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-snapshot-resolver.js
More file actions
22 lines (18 loc) · 923 Bytes
/
Copy pathtest-snapshot-resolver.js
File metadata and controls
22 lines (18 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// ./snapshot-resolver.js
const path = require('path')
// 👉 process.env.TEST_ROOT will only be available in --index-json or --stories-json mode.
// if you run this code without these flags, you will have to override it the test root, else it will break.
// e.g. process.env.TEST_ROOT = process.cwd()
module.exports = {
resolveSnapshotPath: (testPath, snapshotExtension) => {
// Save inside __snapshots__ folder at same level as test file
const testDirectory = path.dirname(testPath)
const testName = path.basename(testPath)
return path.join(testDirectory, '__snapshots__', testName + snapshotExtension)
},
resolveTestPath: (snapshotFilePath, snapshotExtension) => {
const testPath = snapshotFilePath.replace('__snapshots__/', '').replace(/\.snap$/, '')
return testPath
},
testPathForConsistencyCheck: path.join(process.cwd(), 'example.test.js'),
}