Skip to content

Commit 068b315

Browse files
Array Fleetcursoragent
andcommitted
test(cli): probe CLI execution in vitest globalSetup
Run --version after build so smoke tests fail fast with a clear error when runtime dependencies are missing, not only when dist/cli.js is absent. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 43d4ac1 commit 068b315

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

test/global-setup.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { execSync } from "node:child_process";
1+
import { execSync, spawnSync } from "node:child_process";
22
import { existsSync } from "node:fs";
33
import { dirname, join } from "node:path";
44
import { fileURLToPath } from "node:url";
@@ -11,4 +11,16 @@ export default function setup(): void {
1111
if (!existsSync(cli)) {
1212
throw new Error(`CLI build failed: ${cli} not found before running tests`);
1313
}
14+
15+
const probe = spawnSync(process.execPath, [cli, "--version"], {
16+
cwd: repoRoot,
17+
encoding: "utf8",
18+
env: { ...process.env, MEX_TELEMETRY: "0", NO_COLOR: "1" },
19+
});
20+
if (probe.status !== 0) {
21+
const detail = [probe.stdout, probe.stderr].filter(Boolean).join("\n");
22+
throw new Error(
23+
`CLI probe failed (run npm install if dependencies are missing): ${detail}`,
24+
);
25+
}
1426
}

0 commit comments

Comments
 (0)