





















@@ -44,6 +44,18 @@ function createExistingSessionProfileState(params?: {
4444};
4545}
464647+function readFirstReachabilityCall(
48+isReachable: ReturnType<typeof vi.fn>,
49+): [number | undefined, { ephemeral?: boolean; signal?: AbortSignal } | undefined] {
50+const [call] = isReachable.mock.calls as Array<
51+[number | undefined, { ephemeral?: boolean; signal?: AbortSignal } | undefined]
52+>;
53+if (!call) {
54+throw new Error("expected reachability probe call");
55+}
56+return call;
57+}
58+4759function createManagedProfileState() {
4860return {
4961resolved: {
@@ -329,12 +341,7 @@ describe("basic browser routes", () => {
329341expect(response.statusCode).toBe(200);
330342expect(isTransportAvailable).toHaveBeenCalledTimes(1);
331343expect(isTransportAvailable).toHaveBeenCalledWith(5_000);
332-const [timeoutMs, reachabilityOptions] =
333-(
334-isReachable.mock.calls as unknown as Array<
335-[number, { ephemeral?: boolean; signal?: AbortSignal }]
336->
337-)[0] ?? [];
344+const [timeoutMs, reachabilityOptions] = readFirstReachabilityCall(isReachable);
338345expect(timeoutMs).toBe(7_000);
339346expect(reachabilityOptions?.ephemeral).toBe(true);
340347expect(reachabilityOptions?.signal).toBeInstanceOf(AbortSignal);
@@ -362,12 +369,7 @@ describe("basic browser routes", () => {
362369});
363370364371expect(response.statusCode).toBe(200);
365-const [timeoutMs, reachabilityOptions] =
366-(
367-isReachable.mock.calls as unknown as Array<
368-[number, { ephemeral?: boolean; signal?: AbortSignal }]
369->
370-)[0] ?? [];
372+const [timeoutMs, reachabilityOptions] = readFirstReachabilityCall(isReachable);
371373expect(timeoutMs).toBe(4_000);
372374expect(reachabilityOptions?.ephemeral).toBe(true);
373375expect(reachabilityOptions?.signal).toBeInstanceOf(AbortSignal);
@@ -392,8 +394,9 @@ describe("basic browser routes", () => {
392394});
393395394396expect(isReachable).toHaveBeenCalledTimes(1);
395-expect(isReachable.mock.calls[0]?.[1]?.ephemeral).toBe(true);
396-expect(isReachable.mock.calls[0]?.[1]?.signal).toBeInstanceOf(AbortSignal);
397+const [, reachabilityOptions] = readFirstReachabilityCall(isReachable);
398+expect(reachabilityOptions?.ephemeral).toBe(true);
399+expect(reachabilityOptions?.signal).toBeInstanceOf(AbortSignal);
397400});
398401399402it("skips the page-reachability probe when transport is unavailable", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。