From 027701b97d2080841acb106f6673b6d3bd8b8571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 6 Oct 2026 07:56:55 +0200 Subject: [PATCH] test(android): bound the screenshot write wait by wall time, not event-loop turns The rotation-probe test yielded 1,000 setImmediate turns for the PNG write to finish; a loaded libuv thread pool (Coverage CI) can need more, so the grace timer was not yet installed and the test failed. Co-Authored-By: Claude Opus 5.5 (1M context) --- packages/platform-android/src/__tests__/screenshot.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/platform-android/src/__tests__/screenshot.test.ts b/packages/platform-android/src/__tests__/screenshot.test.ts index 44f20f5bd5..445a701520 100644 --- a/packages/platform-android/src/__tests__/screenshot.test.ts +++ b/packages/platform-android/src/__tests__/screenshot.test.ts @@ -99,8 +99,10 @@ test('screenshotAndroid drops a display rotation probe still running after the c facts = result; }); // The image is written through real file I/O; the only timer this path installs is the - // grace that starts once the write is done. Yield to I/O until it exists. - for (let turn = 0; turn < 1_000 && vi.getTimerCount() === 0; turn++) { + // grace that starts once the write is done. Yield to I/O until it exists, bounded by wall + // time because a loaded thread pool can take any number of event-loop turns to finish it. + const writeDeadline = performance.now() + 10_000; + while (vi.getTimerCount() === 0 && performance.now() < writeDeadline) { await new Promise((resolve) => setImmediate(resolve)); } assert.equal(vi.getTimerCount(), 1, 'the capture must start one grace timer once written');