perf(test): cut slow monitor/subagent test overhead

This commit is contained in:
Peter Steinberger
2026-02-18 03:50:22 +00:00
parent 99db4d13e5
commit 797ea7ed27
6 changed files with 50 additions and 84 deletions

View File

@@ -1,4 +1,5 @@
import { describe, expect, it, vi } from "vitest";
import { resolveDiscordRestFetch } from "./rest-fetch.js";
const { undiciFetchMock, proxyAgentSpy } = vi.hoisted(() => ({
undiciFetchMock: vi.fn(),
@@ -31,9 +32,7 @@ describe("resolveDiscordRestFetch", () => {
} as const;
undiciFetchMock.mockReset().mockResolvedValue(new Response("ok", { status: 200 }));
proxyAgentSpy.mockReset();
const { __testing } = await import("./provider.js");
const fetcher = __testing.resolveDiscordRestFetch("http://proxy.test:8080", runtime);
const fetcher = resolveDiscordRestFetch("http://proxy.test:8080", runtime);
await fetcher("https://discord.com/api/v10/oauth2/applications/@me");
@@ -54,9 +53,7 @@ describe("resolveDiscordRestFetch", () => {
error: vi.fn(),
exit: vi.fn(),
} as const;
const { __testing } = await import("./provider.js");
const fetcher = __testing.resolveDiscordRestFetch("bad-proxy", runtime);
const fetcher = resolveDiscordRestFetch("bad-proxy", runtime);
expect(fetcher).toBe(fetch);
expect(runtime.error).toHaveBeenCalled();