




















@@ -278,10 +278,20 @@ function expectRespondErrorContaining(respond: ReturnType<typeof vi.fn>, text: s
278278expect(mockCallArg(respond)).toBe(false);
279279expect(mockCallArg(respond, 0, 1)).toBeUndefined();
280280const error = expectRecordFields(mockCallArg(respond, 0, 2), {});
281-expect(error.message).toEqual(expect.stringContaining(text));
281+expectStringContaining(error.message, text);
282282return error;
283283}
284284285+function expectStringContaining(value: unknown, text: string) {
286+expect(typeof value).toBe("string");
287+expect(value as string).toContain(text);
288+}
289+290+function expectStringNotContaining(value: unknown, text: string) {
291+expect(typeof value).toBe("string");
292+expect(value as string).not.toContain(text);
293+}
294+285295function findMockCallArg(
286296mock: ReturnType<typeof vi.fn>,
287297predicate: (arg: Record<string, unknown>) => boolean,
@@ -568,7 +578,7 @@ describe("agents.create", () => {
568578rootDir: "/resolved/tmp/ws",
569579relativePath: "IDENTITY.md",
570580});
571-expect(write.data).toEqual(expect.stringContaining("- Name: Plain Agent"));
581+expectStringContaining(write.data, "- Name: Plain Agent");
572582});
573583574584it("writes emoji and avatar to both config and IDENTITY.md", async () => {
@@ -882,9 +892,9 @@ describe("agents.update", () => {
882892rootDir: "/resolved/new/workspace",
883893relativePath: "IDENTITY.md",
884894});
885-expect(write.data).toEqual(expect.stringContaining("- **Creature:** Steady Turtle"));
886-expect(write.data).toEqual(expect.stringContaining("## Role"));
887-expect(write.data).not.toEqual(expect.stringContaining("Flustered Protocol Droid"));
895+expectStringContaining(write.data, "- **Creature:** Steady Turtle");
896+expectStringContaining(write.data, "## Role");
897+expectStringNotContaining(write.data, "Flustered Protocol Droid");
888898});
889899890900it("preserves an existing destination identity file when workspace changes", async () => {
@@ -950,9 +960,9 @@ describe("agents.update", () => {
950960rootDir: "/resolved/new/workspace",
951961relativePath: "IDENTITY.md",
952962});
953-expect(write.data).toEqual(expect.stringContaining("- **Creature:** Destination Fox"));
954-expect(write.data).toEqual(expect.stringContaining("Destination workspace role."));
955-expect(write.data).not.toEqual(expect.stringContaining("Old workspace role."));
963+expectStringContaining(write.data, "- **Creature:** Destination Fox");
964+expectStringContaining(write.data, "Destination workspace role.");
965+expectStringNotContaining(write.data, "Old workspace role.");
956966});
957967958968it("does not persist config when IDENTITY.md write fails on update", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。