describe ( 'get-chrome-path' , ( ) : void => { afterEach ( ( ) : void => { jest . resetModules ( ) ; } ) ; test ( 'should return X64 windows path on Windows platform' , ( ) : void => { jest . mock ( 'os' , ( ) : unknown => ( { ... jest . requireActual < object > ( 'os' ) , type : ( ) : string => 'Windows_NT' , } ) ) ; jest . mock ( 'fs' , ( ) : unknown => ( { ... jest . requireActual < object > ( 'fs' ) , existsSync : ( path ) : boolean => { if ( path === 'C:/Program Files/Google/Chrome/Application/chrome.exe' ) { return true ; } return false ; } , } ) ) ; const result = require ( '../get-chrome-path' ) . getChromePath ( ) ; expect ( result ) . toBe ( 'C:/Program Files/Google/Chrome/Application/chrome.exe' ) ; } ) ; test ( 'should return X86 windows path on Windows platform' , ( ) : void => { jest . mock ( 'os' , ( ) : unknown => ( { ... jest . requireActual < object > ( 'os' ) , type : ( ) : string => 'Windows_NT' , } ) ) ; jest . mock ( 'fs' , ( ) : unknown => ( { ... jest . requireActual < object > ( 'fs' ) , existsSync : ( path ) : boolean => { if ( path === 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe' ) { return true ; } return false ; } , } ) ) ; const result = require ( '../get-chrome-path' ) . getChromePath ( ) ; expect ( result ) . toBe ( 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe' ) ; } ) ; test ( 'should return default MacOS path on MAcOS platform' , ( ) : void => { jest . mock ( 'os' , ( ) : unknown => ( { ... jest . requireActual < object > ( 'os' ) , type : ( ) : string => 'Darwin' , } ) ) ; const result = require ( '../get-chrome-path' ) . getChromePath ( ) ; expect ( result ) . toBe ( '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' ) ; } ) ; test ( 'should return default Unix path on Unix platform for google stable install' , ( ) : void => { jest . mock ( 'os' , ( ) : unknown => ( { ... jest . requireActual < object > ( 'os' ) , type : ( ) : string => 'Linux' , } ) ) ; jest . mock ( 'which' , ( ) : unknown => ( { ... jest . requireActual < object > ( 'which' ) , sync : ( input ) : string => input , } ) ) ; const result = require ( '../get-chrome-path' ) . getChromePath ( ) ; expect ( result ) . toBe ( 'google-chrome-stable' ) ; } ) ; test ( 'should return default Unix path on Unix platform for google install' , ( ) : void => { jest . mock ( 'os' , ( ) : unknown => ( { ... jest . requireActual < object > ( 'os' ) , type : ( ) : string => 'Linux' , } ) ) ; jest . mock ( 'which' , ( ) : unknown => ( { ... jest . requireActual < object > ( 'which' ) , sync : ( input ) : string => ( input === 'google-chrome' ? 'google-chrome' : '' ) , } ) ) ; const result = require ( '../get-chrome-path' ) . getChromePath ( ) ; expect ( result ) . toBe ( 'google-chrome' ) ; } ) ; test ( 'should return an error when platform is unknown' , ( ) : void => { jest . mock ( 'os' , ( ) : unknown => ( { ... jest . requireActual < object > ( 'os' ) , type : ( ) : string => 'foo' , } ) ) ; const expectedError = new Error ( 'You should supply the path to the Chrome App in the launch options' ) ; expect ( ( ) : string => require ( '../get-chrome-path' ) . getChromePath ( ) ) . toThrow ( expectedError ) ; } ) ; } ) ;