Skip to content

Commit a37d618

Browse files
committed
test(lib): add bee cli e2e test
1 parent bd0062e commit a37d618

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

sources/lib/lib.e2e.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { describe, expect, it } from "bun:test";
2+
import { createBeeClient } from "@/lib";
3+
import { existsSync } from "node:fs";
4+
import { resolve } from "node:path";
5+
6+
const SHOULD_RUN = process.env["BEE_CLI_E2E"] === "1";
7+
const e2e = SHOULD_RUN ? it : it.skip;
8+
const TIMEOUT_MS = 20000;
9+
10+
const binaryPath = resolve(process.cwd(), "dist", "bee");
11+
12+
describe("bee cli e2e", () => {
13+
e2e(
14+
"runs against real bee binary",
15+
async () => {
16+
if (!existsSync(binaryPath)) {
17+
throw new Error(
18+
`Bee binary not found at ${binaryPath}. Run bun run build first.`
19+
);
20+
}
21+
22+
const bee = createBeeClient({ command: binaryPath });
23+
const version = await bee.api.version<{ name?: string; version?: string }>();
24+
25+
expect(typeof version).toBe("object");
26+
expect(typeof version?.version).toBe("string");
27+
28+
const status = await bee.run(["status"]);
29+
expect(status.exitCode).toBe(0);
30+
expect(status.stdout).toContain("API:");
31+
expect(
32+
status.stdout.includes("Not logged in.") ||
33+
status.stdout.includes("Verified as")
34+
).toBe(true);
35+
},
36+
TIMEOUT_MS
37+
);
38+
});

0 commit comments

Comments
 (0)