diff --git a/extensions/browser/src/browser/pw-tools-core.interactions.batch.test.ts b/extensions/browser/src/browser/pw-tools-core.interactions.batch.test.ts index 3a0ce7c0ec9..7beff563b24 100644 --- a/extensions/browser/src/browser/pw-tools-core.interactions.batch.test.ts +++ b/extensions/browser/src/browser/pw-tools-core.interactions.batch.test.ts @@ -38,6 +38,17 @@ vi.mock("./pw-tools-core.snapshot.js", () => ({ const { batchViaPlaywright } = await import("./pw-tools-core.interactions.js"); +function firstEvaluateCall(): [unknown, { fnBody?: string; timeoutMs?: number }] { + if (!page) { + throw new Error("expected test page"); + } + const [call] = page.evaluate.mock.calls; + if (!call) { + throw new Error("expected page.evaluate call"); + } + return call as [unknown, { fnBody?: string; timeoutMs?: number }]; +} + describe("batchViaPlaywright", () => { beforeEach(() => { vi.clearAllMocks(); @@ -56,7 +67,7 @@ describe("batchViaPlaywright", () => { }); expect(result).toEqual({ results: [{ ok: true }] }); - const [evaluateFn, evaluateOptions] = page?.evaluate.mock.calls[0] ?? []; + const [evaluateFn, evaluateOptions] = firstEvaluateCall(); expect(typeof evaluateFn).toBe("function"); expect(evaluateOptions?.fnBody).toBe("() => 1"); expect(evaluateOptions?.timeoutMs).toBe(4500);