import { join } from 'path' ; const childProcessModule = jest . requireActual ( 'child_process' ) ; const fsModule = jest . requireActual ( 'fs' ) ; export const mockedRootDir = '/root' ; export const packageMock = { raw : { } as any , } ; jest . doMock ( join ( mockedRootDir , 'package.json' ) , ( ) => packageMock . raw , { virtual : true } ) ; export const devConfigMock = { raw : { } as any , } ; jest . doMock ( join ( mockedRootDir , 'config' , 'apm.dev.js' ) , ( ) => devConfigMock . raw , { virtual : true , } ) ; export const gitRevExecMock = jest . fn ( ) ; jest . doMock ( 'child_process' , ( ) => ( { ... childProcessModule , execSync : ( command , options ) => { if ( command . startsWith ( 'git rev-parse' ) ) { return gitRevExecMock ( command , options ) ; } return childProcessModule . execSync ( command , options ) ; } , } ) ) ; export const readUuidFileMock = jest . fn ( ) ; jest . doMock ( 'fs' , ( ) => ( { ... fsModule , readFileSync : ( path , options ) => { if ( path . endsWith ( 'uuid' ) ) { return readUuidFileMock ( path , options ) ; } return fsModule . readFileSync ( path , options ) ; } , } ) ) ; export const resetAllMocks = ( ) => { packageMock . raw = { } ; devConfigMock . raw = { } ; gitRevExecMock . mockReset ( ) ; readUuidFileMock . mockReset ( ) ; jest . resetModules ( ) ; } ;