Skip to content

Commit 5889179

Browse files
committed
Put each snap file in it's own folder and shorten names
1 parent fed5dda commit 5889179

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/rrweb/test/utils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,15 @@ export async function assertSnapshot(
320320

321321
expect(snapshots).toBeDefined();
322322
if (useOwnFile) {
323+
// e.g. 'mutation.test.ts > mutation > add elements at once'
324+
const long_fname = expect.getState().currentTestName.split('/').pop();
325+
const file = long_fname.split(' > ')[0].replace('.test.ts', '');
323326
if (typeof useOwnFile !== 'string') {
324-
// e.g. 'mutation.test.ts > mutation > add elements at once'
325-
useOwnFile = expect.getState().currentTestName.split('/').pop();
327+
useOwnFile = long_fname.substring(long_fname.indexOf(' > ') + 3);
326328
}
327329
useOwnFile = useOwnFile.replace(/ > /g, '.').replace(/\s/g, '_');
328330

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

0 commit comments

Comments
 (0)