From 8ac299ee4952d6b0b65d64d00d31b7ca385bc15a Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 11 May 2026 11:34:12 +0100 Subject: [PATCH] test: tighten browser cdp screenshot assertions --- .../src/browser/cdp.screenshot-params.test.ts | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/extensions/browser/src/browser/cdp.screenshot-params.test.ts b/extensions/browser/src/browser/cdp.screenshot-params.test.ts index 1e6471e28b0..7f75e5057b1 100644 --- a/extensions/browser/src/browser/cdp.screenshot-params.test.ts +++ b/extensions/browser/src/browser/cdp.screenshot-params.test.ts @@ -107,9 +107,7 @@ describe("CDP screenshot params", () => { await captureScreenshot({ wsUrl: "ws://localhost:9222/devtools/page/X", format: "png" }); const call = requireSentMessage("Page.captureScreenshot"); - expect(call.params).toMatchObject({ - format: "png", - }); + expect(call.params?.format).toBe("png"); expect(call.params).not.toHaveProperty("fromSurface"); expect(call.params).not.toHaveProperty("captureBeyondViewport"); expect(call.params).not.toHaveProperty("clip"); @@ -152,27 +150,23 @@ describe("CDP screenshot params", () => { } // Expand: uses saved DPR, mobile defaults to false - expect(firstSetCall.params).toMatchObject({ - width: 1200, - height: 3000, - deviceScaleFactor: 2, - mobile: false, - }); + expect(firstSetCall.params?.width).toBe(1200); + expect(firstSetCall.params?.height).toBe(3000); + expect(firstSetCall.params?.deviceScaleFactor).toBe(2); + expect(firstSetCall.params?.mobile).toBe(false); // Clear is called first in the finally block requireSentMessage("Emulation.clearDeviceMetricsOverride"); const captureCall = requireSentMessage("Page.captureScreenshot"); - expect(captureCall.params).toMatchObject({ captureBeyondViewport: true }); + expect(captureCall.params?.captureBeyondViewport).toBe(true); // Viewport drifted after clear → re-apply saved dimensions - expect(secondSetCall.params).toMatchObject({ - width: 800, - height: 600, - deviceScaleFactor: 2, - mobile: false, - screenWidth: 800, - screenHeight: 600, - }); + expect(secondSetCall.params?.width).toBe(800); + expect(secondSetCall.params?.height).toBe(600); + expect(secondSetCall.params?.deviceScaleFactor).toBe(2); + expect(secondSetCall.params?.mobile).toBe(false); + expect(secondSetCall.params?.screenWidth).toBe(800); + expect(secondSetCall.params?.screenHeight).toBe(600); }); it("fullPage on non-emulated tab: clears and does NOT re-apply emulation", async () => {