Skip to content

Commit 1d1d0ca

Browse files
committed
fix: preserve macOS runner screenshots
1 parent ec311d0 commit 1d1d0ca

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎src/platforms/apple/core/__tests__/index.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,23 @@ test('captureScreenshotViaRunner reuses a verified simulator container path', as
12561256
}
12571257
});
12581258

1259+
test('captureScreenshotViaRunner copies macOS runner screenshots from the host', async () => {
1260+
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), 'agent-device-macos-screenshot-'));
1261+
const sourcePath = path.join(tmpDir, 'runner.png');
1262+
const outPath = path.join(tmpDir, 'screen.png');
1263+
await fs.writeFile(sourcePath, 'runner-image', 'utf8');
1264+
mockRunAppleRunnerCommand.mockResolvedValue({ message: sourcePath });
1265+
mockRunCmd.mockRejectedValue(new Error('macOS screenshot must not invoke xcrun devicectl'));
1266+
1267+
try {
1268+
await captureScreenshotViaRunner(MACOS_TEST_DEVICE, outPath);
1269+
assert.equal(await fs.readFile(outPath, 'utf8'), 'runner-image');
1270+
assert.equal(mockRunCmd.mock.calls.length, 0);
1271+
} finally {
1272+
await fs.rm(tmpDir, { recursive: true, force: true });
1273+
}
1274+
});
1275+
12591276
test('screenshotIos retries simulator capture timeouts and eventually succeeds', async () => {
12601277
const tmpDir = await fs.mkdtemp(
12611278
path.join(os.tmpdir(), 'agent-device-ios-screenshot-retry-test-'),

‎src/platforms/apple/core/screenshot.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export async function captureScreenshotViaRunner(
194194
fullscreen?: boolean,
195195
runnerOptions?: AppleRunnerCommandOptions,
196196
): Promise<void> {
197-
if (device.kind === 'device') {
197+
if (device.kind === 'device' && !isMacOs(device)) {
198198
await resolveIosPhysicalDeviceControl(device).captureScreenshot(device, outPath, {
199199
appBundleId,
200200
fullscreen,

0 commit comments

Comments
 (0)