diff --git a/frontend/src/setupTests.ts b/frontend/src/setupTests.ts index 3de2908..0f1a560 100644 --- a/frontend/src/setupTests.ts +++ b/frontend/src/setupTests.ts @@ -7,8 +7,14 @@ import { beforeEach, vi } from "vitest"; beforeEach(() => { vi.stubGlobal( "fetch", - vi.fn(() => - Promise.resolve(new Response(JSON.stringify({}), { status: 200 })), - ), + vi.fn((input: string | URL | Request) => { + const url = typeof input === "string" ? input : input.toString(); + // Endpoints that return arrays need [] not {} to avoid "not iterable" errors. + const arrayEndpoints = ["/agents", "/agents/config"]; + const body = arrayEndpoints.some((ep) => url.endsWith(ep)) + ? JSON.stringify([]) + : JSON.stringify({}); + return Promise.resolve(new Response(body, { status: 200 })); + }), ); });