@@ -15,7 +15,7 @@ addSerializer(serializer);
15
15
// prettier-ignore
16
16
const ONLY = [ ] . join ( path . sep ) ;
17
17
18
- const FIXTURES_DIR = path . resolve (
18
+ const fixturesDir = path . resolve (
19
19
__dirname ,
20
20
'..' ,
21
21
'..' ,
@@ -25,15 +25,15 @@ const FIXTURES_DIR = path.resolve(
25
25
'shared-fixtures' ,
26
26
'fixtures' ,
27
27
) ;
28
- const SNAPSHOTS_DIR = path . resolve ( __dirname , 'snapshots' ) ;
28
+ const snapshotsDir = path . resolve ( __dirname , 'snapshots' ) ;
29
29
30
30
const fixtures = glob
31
- . sync ( `${ FIXTURES_DIR } / **/*.src.{js,ts,jsx,tsx}` )
31
+ . sync ( `**/*.src.{js,ts,jsx,tsx}` , { cwd : fixturesDir , absolute : true } )
32
32
. map ( absolute => {
33
- const relative = path . relative ( FIXTURES_DIR , absolute ) ;
33
+ const relative = path . relative ( fixturesDir , absolute ) ;
34
34
const { name, dir, ext } = path . parse ( relative ) ;
35
35
const segments = dir . split ( path . sep ) ;
36
- const snapshotPath = path . join ( SNAPSHOTS_DIR , dir ) ;
36
+ const snapshotPath = path . join ( snapshotsDir , dir ) ;
37
37
return {
38
38
absolute,
39
39
isJsx : isJSXFileType ( ext ) ,
@@ -97,14 +97,16 @@ fixtures.forEach(f => nestDescribe(f));
97
97
98
98
if ( ONLY === '' ) {
99
99
// ensure that the snapshots are cleaned up, because jest-specific-snapshot won't do this check
100
- const snapshots = glob . sync ( `${ SNAPSHOTS_DIR } /**/*.shot` ) . map ( absolute => {
101
- const relative = path . relative ( SNAPSHOTS_DIR , absolute ) ;
102
- const { name, dir } = path . parse ( relative ) ;
103
- return {
104
- relative,
105
- fixturePath : path . join ( FIXTURES_DIR , dir , name ) ,
106
- } ;
107
- } ) ;
100
+ const snapshots = glob
101
+ . sync ( `**/*.shot` , { cwd : snapshotsDir , absolute : true } )
102
+ . map ( absolute => {
103
+ const relative = path . relative ( snapshotsDir , absolute ) ;
104
+ const { name, dir } = path . parse ( relative ) ;
105
+ return {
106
+ relative,
107
+ fixturePath : path . join ( fixturesDir , dir , name ) ,
108
+ } ;
109
+ } ) ;
108
110
109
111
describe ( 'ast snapshots should have an associated test' , ( ) => {
110
112
for ( const snap of snapshots ) {
0 commit comments