Skip to content

Commit 13839c2

Browse files
committed
test(browser): use a real Response in 429 regression
1 parent 7d80e4f commit 13839c2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/browser/client-fetch.loopback-auth.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,12 @@ describe("fetchBrowserJson loopback auth", () => {
139139
});
140140

141141
it("surfaces 429 from HTTP URL as rate-limit error with no-retry hint", async () => {
142-
const text = vi.fn(async () => "max concurrent sessions exceeded");
143-
const cancel = vi.fn(async () => {});
142+
const response = new Response("max concurrent sessions exceeded", { status: 429 });
143+
const text = vi.spyOn(response, "text");
144+
const cancel = vi.spyOn(response.body!, "cancel").mockResolvedValue(undefined);
144145
vi.stubGlobal(
145146
"fetch",
146-
vi.fn(async () => ({ ok: false, status: 429, text, body: { cancel } }) as Response),
147+
vi.fn(async () => response),
147148
);
148149

149150
const thrown = await fetchBrowserJson<{ ok: boolean }>("http://127.0.0.1:18888/").catch(

0 commit comments

Comments
 (0)