





















@@ -47,7 +47,7 @@ function warnMessages(): string[] {
4747}
48484949function expectWarnContaining(fragment: string) {
50-expect(warnMessages().some((message) => message.includes(fragment))).toBe(true);
50+expect(warnMessages().join("\n")).toContain(fragment);
5151}
52525353function mockCall(mock: ReturnType<typeof vi.fn>, index = 0): unknown[] {
@@ -379,7 +379,7 @@ describe("gateway bonjour advertiser", () => {
379379([event]) => event === "unhandledRejection",
380380);
381381expect(unhandledRejectionRegistration?.[1]).toBeTypeOf("function");
382-expect(processOn.mock.calls.some(([event]) => event === "uncaughtException")).toBe(false);
382+expect(processOn.mock.calls.map(([event]) => event)).not.toContain("uncaughtException");
383383384384await started.stop();
385385});
@@ -496,7 +496,7 @@ describe("gateway bonjour advertiser", () => {
496496});
497497498498expectWarnContaining("suppressing ciao cancellation");
499-expect(warnMessages().some((message) => message.includes("restarting advertiser"))).toBe(true);
499+expectWarnContaining("restarting advertiser");
500500expect(destroy).toHaveBeenCalledTimes(1);
501501expect(advertise).toHaveBeenCalledTimes(2);
502502@@ -524,7 +524,7 @@ describe("gateway bonjour advertiser", () => {
524524525525// allow promise rejection handler to run
526526await Promise.resolve();
527-expect(warnMessages().some((message) => message.includes("advertise failed"))).toBe(true);
527+expectWarnContaining("advertise failed");
528528529529// watchdog first retries, then recreates the advertiser after the service
530530// stays unhealthy across multiple 5s ticks.
@@ -553,7 +553,7 @@ describe("gateway bonjour advertiser", () => {
553553});
554554555555expect(advertise).toHaveBeenCalledTimes(1);
556-expect(warnMessages().some((message) => message.includes("advertise threw"))).toBe(true);
556+expectWarnContaining("advertise threw");
557557558558await started.stop();
559559});
@@ -687,7 +687,7 @@ describe("gateway bonjour advertiser", () => {
687687688688await vi.advanceTimersByTimeAsync(25_000);
689689690-expect(warnMessages().some((message) => message.includes("restarting advertiser"))).toBe(true);
690+expectWarnContaining("restarting advertiser");
691691expect(createService).toHaveBeenCalledTimes(2);
692692expect(advertise).toHaveBeenCalledTimes(2);
693693expect(destroy).toHaveBeenCalledTimes(1);
@@ -756,11 +756,8 @@ describe("gateway bonjour advertiser", () => {
756756757757expect(advertise).toHaveBeenCalledTimes(1);
758758expect(createService).toHaveBeenCalledTimes(1);
759-expect(
760-warnMessages().every(
761-(message) =>
762-!message.includes("watchdog detected non-announced service; attempting re-advertise"),
763-),
759+expect(warnMessages().join("\n")).not.toContain(
760+"watchdog detected non-announced service; attempting re-advertise",
764761);
765762766763await vi.advanceTimersByTimeAsync(10_000);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。