im_wower
·
2026-03-22
smoke.test.js
1import assert from "node:assert/strict";
2import { mkdtemp, rm } from "node:fs/promises";
3import { tmpdir } from "node:os";
4import { join } from "node:path";
5import test from "node:test";
6
7import { runCodexExec } from "../dist/index.js";
8
9test("runCodexExec can drive the real codex exec CLI for smoke coverage", async (t) => {
10 if (process.env.BAA_RUN_LIVE_CODEX_EXEC_SMOKE !== "1") {
11 t.skip("Set BAA_RUN_LIVE_CODEX_EXEC_SMOKE=1 to run the live codex exec smoke test.");
12 }
13
14 const workspacePath = await mkdtemp(join(tmpdir(), "baa-codex-exec-smoke-"));
15
16 t.after(async () => {
17 await rm(workspacePath, { force: true, recursive: true });
18 });
19
20 const response = await runCodexExec({
21 purpose: "smoke",
22 prompt: "Reply with a short confirmation sentence.",
23 cwd: workspacePath,
24 timeoutMs: 120_000,
25 sandbox: "read-only",
26 skipGitRepoCheck: true,
27 ephemeral: true
28 });
29
30 assert.equal(response.ok, true, response.ok ? undefined : response.error.message);
31 assert.equal(response.result.exitCode, 0);
32 assert.equal(response.result.timedOut, false);
33 assert.notEqual(response.result.lastMessage, null);
34 assert.notEqual(response.result.lastMessage?.trim(), "");
35});