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.
This commit is contained in:
Priyanshu Choudhary 2026-04-25 17:40:06 +05:30
parent f0eec60dfb
commit c1e775c925
1 changed files with 6 additions and 0 deletions

View File

@ -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"]);