Skip to content

Commit

Permalink
chore: adding file nesting for tests snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienIzz committed Feb 1, 2024
1 parent 21564d3 commit be473cd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.patterns": {
"*.test.ts": "${capture}.test.ts.snap",
"*.test.tsx": "${capture}.test.tsx.snap",
".eslintrc.js": "*.eslintrc.js"
}
}
1 change: 1 addition & 0 deletions packages/lib/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const config = {
// tools
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
reporters: ['default', 'github-actions'], // Remove this line if your CI is not on Github actions
snapshotResolver: './jestSnapshotResolver.js',
};

module.exports = config;
11 changes: 11 additions & 0 deletions packages/lib/jestSnapshotResolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
testPathForConsistencyCheck: 'some/__tests__/example.test.js',
/** resolves from test to snapshot path */
resolveSnapshotPath: (testPath, snapshotExtension) => {
return testPath + snapshotExtension;
},
/** resolves from snapshot to test path */
resolveTestPath: (snapshotFilePath, snapshotExtension) => {
return snapshotFilePath.slice(0, -snapshotExtension.length);
},
};

0 comments on commit be473cd

Please sign in to comment.