Skip to content

Instantly share code, notes, and snippets.

@thisismydesign
Last active November 3, 2018 20:14
Show Gist options
  • Save thisismydesign/41280060c46697673fa8d957b85b5f4f to your computer and use it in GitHub Desktop.
Save thisismydesign/41280060c46697673fa8d957b85b5f4f to your computer and use it in GitHub Desktop.
No more __snapshots__ folders with Jest! - example configuration
// config/snapshotResolver.js
module.exports = {
resolveSnapshotPath: (testPath, snapshotExtension) => testPath + snapshotExtension,
resolveTestPath: (snapshotFilePath, snapshotExtension) => snapshotFilePath.slice(0, -snapshotExtension.length),
};
// package.json
"jest": {
"snapshotResolver": "<rootDir>/config/snapshotResolver.js"
}
// Results in:
// .
// ├── src
// │   ├── components
// │   │   ├── App
// │   │   │   ├── App.js
// │   │   │   ├── App.test.js
// │   │   │   ├── App.test.js.snap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment