diff --git a/src/discord/monitor/provider.proxy.test.ts b/src/discord/monitor/provider.proxy.test.ts index 410bf35069..365a82de72 100644 --- a/src/discord/monitor/provider.proxy.test.ts +++ b/src/discord/monitor/provider.proxy.test.ts @@ -70,6 +70,16 @@ vi.mock("ws", () => ({ })); describe("createDiscordGatewayPlugin", () => { + function createRuntime() { + return { + log: vi.fn(), + error: vi.fn(), + exit: vi.fn(() => { + throw new Error("exit"); + }), + }; + } + beforeEach(() => { proxyAgentSpy.mockReset(); webSocketSpy.mockReset(); @@ -78,14 +88,7 @@ describe("createDiscordGatewayPlugin", () => { it("uses proxy agent for gateway WebSocket when configured", async () => { const { createDiscordGatewayPlugin } = await import("./gateway-plugin.js"); - - const runtime = { - log: vi.fn(), - error: vi.fn(), - exit: vi.fn(() => { - throw new Error("exit"); - }), - }; + const runtime = createRuntime(); const plugin = createDiscordGatewayPlugin({ discordConfig: { proxy: "http://proxy.test:8080" }, @@ -109,14 +112,7 @@ describe("createDiscordGatewayPlugin", () => { it("falls back to the default gateway plugin when proxy is invalid", async () => { const { createDiscordGatewayPlugin } = await import("./gateway-plugin.js"); - - const runtime = { - log: vi.fn(), - error: vi.fn(), - exit: vi.fn(() => { - throw new Error("exit"); - }), - }; + const runtime = createRuntime(); const plugin = createDiscordGatewayPlugin({ discordConfig: { proxy: "bad-proxy" },