perf(test): avoid proxy runtime dynamic import

This commit is contained in:
Peter Steinberger
2026-04-20 21:02:13 +01:00
parent 3df9a60b0b
commit fffb7d3d7a

View File

@@ -1,4 +1,5 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { finalizeDebugProxyCapture, initializeDebugProxyCapture } from "./runtime.js";
const storeState = vi.hoisted(() => {
const events: Record<string, unknown>[] = [];
@@ -68,14 +69,13 @@ describe("debug proxy runtime", () => {
it("captures ambient global fetch calls when debug proxy mode is enabled", async () => {
globalThis.fetch = vi.fn(async () => ({ status: 200 }) as Response) as typeof fetch;
const runtime = await import("./runtime.js");
runtime.initializeDebugProxyCapture("test");
initializeDebugProxyCapture("test");
await globalThis.fetch("https://api.minimax.io/anthropic/messages", {
method: "POST",
headers: { "content-type": "application/json" },
body: '{"input":"hello"}',
});
runtime.finalizeDebugProxyCapture();
finalizeDebugProxyCapture();
const events = storeState.events.filter((event) => event.sessionId === "runtime-test-session");
expect(events.some((event) => event.host === "api.minimax.io")).toBe(true);