diff --git a/src/browser/client-fetch.loopback-auth.test.ts b/src/browser/client-fetch.loopback-auth.test.ts index 1fe4e3b5c02..7967d11c76e 100644 --- a/src/browser/client-fetch.loopback-auth.test.ts +++ b/src/browser/client-fetch.loopback-auth.test.ts @@ -139,11 +139,12 @@ describe("fetchBrowserJson loopback auth", () => { }); it("surfaces 429 from HTTP URL as rate-limit error with no-retry hint", async () => { - const text = vi.fn(async () => "max concurrent sessions exceeded"); - const cancel = vi.fn(async () => {}); + const response = new Response("max concurrent sessions exceeded", { status: 429 }); + const text = vi.spyOn(response, "text"); + const cancel = vi.spyOn(response.body!, "cancel").mockResolvedValue(undefined); vi.stubGlobal( "fetch", - vi.fn(async () => ({ ok: false, status: 429, text, body: { cancel } }) as Response), + vi.fn(async () => response), ); const thrown = await fetchBrowserJson<{ ok: boolean }>("http://127.0.0.1:18888/").catch(