From c1e775c9256fbb0d6ec8a9fefd631c9fcf84126c Mon Sep 17 00:00:00 2001 From: Priyanshu Choudhary <57816400+Priyanchew@users.noreply.github.com> Date: Sat, 25 Apr 2026 17:40:06 +0530 Subject: [PATCH] test(cli): mock exec for ps verification in stop test killDashboardOnPort runs a unix-only `ps` cmdline check before killing. Without mocking exec, the call rejects and the catch returns false, so killProcessTree is never called and the assertion fails on Linux CI. --- packages/cli/__tests__/commands/start.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/cli/__tests__/commands/start.test.ts b/packages/cli/__tests__/commands/start.test.ts index 4fdef1683..19ed6027c 100644 --- a/packages/cli/__tests__/commands/start.test.ts +++ b/packages/cli/__tests__/commands/start.test.ts @@ -1569,6 +1569,12 @@ describe("stop command", () => { mockConfigRef.current = makeConfig({ "my-app": makeProject() }); mockSessionManager.list.mockResolvedValue([]); mockFindPidByPort.mockResolvedValue("1234"); + // killDashboardOnPort verifies the PID is an AO dashboard via `ps` on Unix + // before killing. Stub it to return a matching cmdline so we reach the kill. + mockExec.mockImplementation(async (cmd: string) => { + if (cmd === "ps") return { stdout: "node /fake/web/dist-server/start-all.js", stderr: "" }; + throw new Error("no process"); + }); await program.parseAsync(["node", "test", "stop"]);