

























@@ -37,6 +37,18 @@ function createRuntime() {
3737return { log: vi.fn(), error: vi.fn(), exit: vi.fn() };
3838}
393940+function runtimeErrorMessageAt(runtime: ReturnType<typeof createRuntime>, index: number): string {
41+const call = runtime.error.mock.calls[index];
42+if (!call || typeof call[0] !== "string") {
43+throw new Error(`expected runtime error call ${index + 1}`);
44+}
45+return call[0];
46+}
47+48+function latestRuntimeErrorMessage(runtime: ReturnType<typeof createRuntime>): string {
49+return runtimeErrorMessageAt(runtime, runtime.error.mock.calls.length - 1);
50+}
51+4052describe("waitForTransportReady", () => {
4153beforeAll(async () => {
4254({ waitForTransportReady } = await import("./transport-ready.js"));
@@ -152,8 +164,8 @@ describe("waitForTransportReady", () => {
152164await asserted;
153165154166expect(runtime.error).toHaveBeenCalledTimes(2);
155-expect(runtime.error.mock.calls.at(0)?.[0]).toContain("unknown error");
156-expect(runtime.error.mock.calls.at(-1)?.[0]).toContain("not ready after 120ms");
167+expect(runtimeErrorMessageAt(runtime, 0)).toContain("unknown error");
168+expect(latestRuntimeErrorMessage(runtime)).toContain("not ready after 120ms");
157169});
158170159171it("rethrows non-abort sleep failures", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。