File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 1
1
import * as path from "node:path" ;
2
+ import * as fs from "node:fs" ;
2
3
import { snapshot } from "node:test" ;
3
4
4
5
snapshot . setResolveSnapshotPath ( testFilePath => {
5
6
const base = path . dirname ( testFilePath ) ;
6
7
const filename = path . basename ( testFilePath ) ;
7
8
return path . resolve ( base , "__snapshots__" , `${ filename } .snap` ) ;
8
9
} ) ;
10
+
11
+ // If there's no private-config.json (e.g., as there is on CI), copy the private-config.sample.json there.
12
+ // This is especially necessary since Node.js's module mocking doesn't work on files that don't exist.
13
+ const privateConfigPath = path . resolve ( import . meta. dirname , "../private-config.json" ) ;
14
+ const privateConfigSamplePath = path . resolve ( import . meta. dirname , "../private-config.sample.json" ) ;
15
+ try {
16
+ fs . copyFileSync ( privateConfigSamplePath , privateConfigPath , fs . constants . COPYFILE_EXCL ) ;
17
+ } catch ( e ) {
18
+ if ( e . code !== "EEXIST" ) {
19
+ throw e ;
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments