File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff 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 ( ) ;
You can’t perform that action at this time.
0 commit comments