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 11import * as path from "node:path" ;
2+ import * as fs from "node:fs" ;
23import { snapshot } from "node:test" ;
34
45snapshot . setResolveSnapshotPath ( testFilePath => {
56 const base = path . dirname ( testFilePath ) ;
67 const filename = path . basename ( testFilePath ) ;
78 return path . resolve ( base , "__snapshots__" , `${ filename } .snap` ) ;
89} ) ;
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