Jest snapshot resolver for snapshots at top level of repo when tests are in component folders.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path') | |
const rootDir = path.resolve(__dirname, '..') | |
module.exports = { | |
/** resolves from test to snapshot path */ | |
resolveSnapshotPath: (testPath, snapshotExtension) => { | |
return testPath.replace('src/', '__snapshots__/') + snapshotExtension | |
}, | |
/** resolves from snapshot to test path */ | |
resolveTestPath: (snapshotFilePath, snapshotExtension) => { | |
return snapshotFilePath | |
.replace('__snapshots__/', 'src/') | |
.slice(0, -snapshotExtension.length) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice. Needed to add
testPathForConsistencyCheck: 'some/__tests__/example.test.js',
at the end though (Jest 24.1.0).