diff --git a/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx b/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx index 85d809636..69a28eaf0 100644 --- a/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx +++ b/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx @@ -36,18 +36,19 @@ export interface IOSBridge { class IDBBridge implements IOSBridge { constructor(private idbPath: string) {} + async navigate(serial: string, location: string): Promise { - exec(`idb open --udid ${serial} "${location}"`); + this._execIdb(`open --udid ${serial} "${location}"`); } recordVideo(serial: string, outputFile: string): child_process.ChildProcess { console.log(`Starting screen record via idb to ${outputFile}.`); - return exec(`idb record-video --udid ${serial} ${outputFile}`); + return this._execIdb(`record-video --udid ${serial} ${outputFile}`); } async screenshot(serial: string): Promise { const imagePath = makeTempScreenshotFilePath(); - await exec(`idb screenshot --udid ${serial} ${imagePath}`); + await this._execIdb(`screenshot --udid ${serial} ${imagePath}`); return readScreenshotIntoBuffer(imagePath); } @@ -65,6 +66,10 @@ class IDBBridge implements IOSBridge { }, ); } + + _execIdb(command: string): child_process.ChildProcess { + return exec(`${this.idbPath} ${command}`); + } } class SimctlBridge implements IOSBridge { diff --git a/desktop/flipper-server-core/src/devices/ios/__tests__/IOSBridge.node.tsx b/desktop/flipper-server-core/src/devices/ios/__tests__/IOSBridge.node.tsx index ad0cc8a66..fa386921c 100644 --- a/desktop/flipper-server-core/src/devices/ios/__tests__/IOSBridge.node.tsx +++ b/desktop/flipper-server-core/src/devices/ios/__tests__/IOSBridge.node.tsx @@ -128,7 +128,7 @@ test.unix('uses idb to take screenshots when available', async () => { await expect(() => ib.screenshot('deadbeef')).rejects.toThrow(); expect((promisifyChildProcess.exec as any).mock.calls[0][0]).toMatch( - 'idb screenshot --udid deadbeef ', + '/usr/local/bin/idb screenshot --udid deadbeef ', ); }); @@ -148,7 +148,7 @@ test('uses idb to navigate when available', async () => { await ib.navigate('deadbeef', 'fb://dummy'); expect(promisifyChildProcess.exec).toHaveBeenCalledWith( - 'idb open --udid deadbeef "fb://dummy"', + '/usr/local/bin/idb open --udid deadbeef "fb://dummy"', ); }); @@ -168,6 +168,6 @@ test('uses idb to record when available', async () => { ib.recordVideo('deadbeef', '/tmo/video.mp4'); expect(promisifyChildProcess.exec).toHaveBeenCalledWith( - 'idb record-video --udid deadbeef /tmo/video.mp4', + '/usr/local/bin/idb record-video --udid deadbeef /tmo/video.mp4', ); });