diff --git a/src/cli/program/command-registry.test.ts b/src/cli/program/command-registry.test.ts index c6c2bbc06d2..231d1f09dd9 100644 --- a/src/cli/program/command-registry.test.ts +++ b/src/cli/program/command-registry.test.ts @@ -173,8 +173,10 @@ describe("command-registry", () => { } const names = namesOf(program); - expect(names.filter((name) => name === "commitments")).toHaveLength(1); - expect(names.filter((name) => name === "tasks")).toHaveLength(1); + const countName = (target: string) => + names.reduce((count, name) => count + (name === target ? 1 : 0), 0); + expect(countName("commitments")).toBe(1); + expect(countName("tasks")).toBe(1); }); it("replaces placeholders when loading a grouped entry by secondary command name", async () => { diff --git a/src/cli/program/register.subclis.test.ts b/src/cli/program/register.subclis.test.ts index 601975fa741..9cea56efd08 100644 --- a/src/cli/program/register.subclis.test.ts +++ b/src/cli/program/register.subclis.test.ts @@ -192,7 +192,7 @@ describe("registerSubCliCommands", () => { await registerSubCliByName(program, "acp"); const names = program.commands.map((cmd) => cmd.name()); - expect(names.filter((name) => name === "acp")).toHaveLength(1); + expect(names.reduce((count, name) => count + (name === "acp" ? 1 : 0), 0)).toBe(1); await program.parseAsync(["acp"], { from: "user" }); expect(registerAcpCli).toHaveBeenCalledTimes(1); diff --git a/src/plugins/cli.test.ts b/src/plugins/cli.test.ts index 8217025062c..fa6167be265 100644 --- a/src/plugins/cli.test.ts +++ b/src/plugins/cli.test.ts @@ -397,7 +397,9 @@ describe("registerPluginCliCommands", () => { primary: "memory", }); - expect(program.commands.filter((command) => command.name() === "memory")).toHaveLength(1); + expect( + program.commands.reduce((count, command) => count + (command.name() === "memory" ? 1 : 0), 0), + ).toBe(1); expect(mocks.loadOpenClawPlugins).toHaveBeenCalledWith( expect.objectContaining({ onlyPluginIds: ["memory-core"],