


























@@ -6,6 +6,15 @@ import {
66createDiscordGatewaySupervisor,
77} from "./gateway-supervisor.js";
889+function firstErrorArg(runtime: { error: ReturnType<typeof vi.fn> }): unknown {
10+const [call] = runtime.error.mock.calls;
11+if (!call) {
12+throw new Error("expected runtime.error call");
13+}
14+expect(call).toHaveLength(1);
15+return call[0];
16+}
17+918describe("classifyDiscordGatewayEvent", () => {
1019it("maps current gateway errors onto domain events", () => {
1120const transientTypeError = new TypeError();
@@ -86,8 +95,7 @@ describe("createDiscordGatewaySupervisor", () => {
86958796expect(seen).toEqual(["disallowed-intents", "fatal"]);
8897expect(runtime.error).toHaveBeenCalledTimes(1);
89-expect(runtime.error.mock.calls[0]).toHaveLength(1);
90-expect(String(runtime.error.mock.calls[0]?.[0])).toContain(
98+expect(String(firstErrorArg(runtime))).toContain(
9199"suppressed late gateway reconnect-exhausted error during teardown",
92100);
93101});
@@ -119,8 +127,7 @@ describe("createDiscordGatewaySupervisor", () => {
119127120128emitter.emit("error", new Error("Max reconnect attempts (0) reached after close code 1005"));
121129expect(runtime.error).toHaveBeenCalledTimes(1);
122-expect(runtime.error.mock.calls[0]).toHaveLength(1);
123-expect(String(runtime.error.mock.calls[0]?.[0])).toContain(
130+expect(String(firstErrorArg(runtime))).toContain(
124131"suppressed late gateway reconnect-exhausted error after dispose",
125132);
126133});
@@ -143,8 +150,7 @@ describe("createDiscordGatewaySupervisor", () => {
143150emitter.emit("error", second);
144151145152expect(runtime.error).toHaveBeenCalledTimes(1);
146-expect(runtime.error.mock.calls[0]).toHaveLength(1);
147-expect(String(runtime.error.mock.calls[0]?.[0])).toContain(
153+expect(String(firstErrorArg(runtime))).toContain(
148154"suppressed late gateway fatal error after dispose: TypeError @ gatewayCrash (discord-gateway.js:12:34)",
149155);
150156});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。