Skip to content

Commit 2c9121c

Browse files
test(server): await native resize before snapshot capture
1 parent 830ed42 commit 2c9121c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎apps/server/src/preview/ServerBrowserPage.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,16 @@ it("captures the native display viewport after page script reassigns the globals
409409
offset: { x: 0, y: 0 },
410410
});
411411
const { windowId } = await cdp.send("Browser.getWindowForTarget");
412+
// CDP acknowledges the bounds change before the renderer applies the resize.
413+
const resize = await page.evaluateHandle(`({
414+
done: new Promise(resolve => window.addEventListener("resize", () => resolve(), { once: true })),
415+
})`);
412416
await cdp.send("Browser.setWindowBounds", {
413417
windowId,
414418
bounds: { width: 390, height: 844 },
415419
});
420+
await resize.evaluate("resize => resize.done");
421+
await resize.dispose();
416422
expect(await snapshotSize()).toEqual({ width: 585, height: 1266 });
417423
} finally {
418424
await browser.close();

0 commit comments

Comments
 (0)