Skip to content

Commit 9a16cce

Browse files
committedFeb 12, 2025
Put each snap file in it's own folder and shorten names
1 parent 1149d3a commit 9a16cce

10 files changed

+5
-3
lines changed
 

‎packages/rrweb/test/utils.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,15 @@ export async function assertSnapshot(
321321
expect(snapshots).toBeDefined();
322322

323323
if (useOwnFile) {
324+
// e.g. 'mutation.test.ts > mutation > add elements at once'
325+
const long_fname = expect.getState().currentTestName.split('/').pop();
326+
const file = long_fname.split(' > ')[0].replace('.test.ts', '');
324327
if (typeof useOwnFile !== 'string') {
325-
// e.g. 'mutation.test.ts > mutation > add elements at once'
326-
useOwnFile = expect.getState().currentTestName.split('/').pop();
328+
useOwnFile = long_fname.substring(long_fname.indexOf(' > ') + 3);
327329
}
328330
useOwnFile = useOwnFile.replace(/ > /g, '.').replace(/\s/g, '_');
329331

330-
const fname = `./__snapshots__/${useOwnFile}.snap.json`;
332+
const fname = `./__${file}.snapshots__/${useOwnFile}.json`;
331333
expect(stringifySnapshots(snapshots)).toMatchFileSnapshot(fname);
332334
} else {
333335
expect(stringifySnapshots(snapshots)).toMatchSnapshot();

0 commit comments

Comments
 (0)