test: suppress expected nodes run stderr noise

This commit is contained in:
Peter Steinberger
2026-04-03 10:42:13 +01:00
parent 1a68e55f47
commit ad6fdf1e3c

View File

@@ -85,6 +85,17 @@ vi.mock("../runtime.js", async (importOriginal) => ({
describe("nodes-cli coverage", () => {
let sharedProgram: Command = new Command();
const withSuppressedStderr = async <T>(run: () => Promise<T>) => {
const stderrSpy = vi
.spyOn(process.stderr, "write")
.mockImplementation((() => true) as typeof process.stderr.write);
try {
return await run();
} finally {
stderrSpy.mockRestore();
}
};
const getNodeInvokeCall = () => {
const last = lastNodeInvokeCall;
if (!last) {
@@ -116,10 +127,12 @@ describe("nodes-cli coverage", () => {
});
it("does not register the removed run wrapper", async () => {
await expect(
sharedProgram.parseAsync(["nodes", "run", "--node", "mac-1"], { from: "user" }),
).rejects.toMatchObject({
code: "commander.unknownCommand",
await withSuppressedStderr(async () => {
await expect(
sharedProgram.parseAsync(["nodes", "run", "--node", "mac-1"], { from: "user" }),
).rejects.toMatchObject({
code: "commander.unknownCommand",
});
});
});