Files
suaveplan/packages/api-stack/api/create-suaveplan-plugin/tests/scaffold-output/runs-bun-test.test.ts
2026-05-27 23:29:53 +01:00

46 lines
1.7 KiB
TypeScript

import { spawnSync } from "node:child_process";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { describe, expect, it } from "@suaveplan/testing/runner";
import { scaffold } from "../../src/generator/generator.js";
import { answersForFixture } from "../../src/prompt/prompt.js";
type Fixture =
| "trusted-postgres-full"
| "isolated-sqlite-rest-only"
| "sandboxed-none-rest-only";
const FIXTURES: readonly Fixture[] = [
"trusted-postgres-full",
"isolated-sqlite-rest-only",
"sandboxed-none-rest-only",
] as const;
describe("scaffold-output: every fixture passes bun test on first run", () => {
for (const fixture of FIXTURES) {
it(`every fixture passes bun test on first run :: ${fixture}`, {
timeout: 30000,
}, () => {
const root = mkdtempSync(join(tmpdir(), `cspp-bun-${fixture}-`));
try {
const answers = answersForFixture(fixture, "demo-plugin");
scaffold({ answers, targetDir: root, force: true });
const result = spawnSync("bun", ["test"], {
cwd: root,
encoding: "utf8",
env: { ...process.env, INTEGRATION: "0" },
});
if (result.status !== 0) {
// Surface output to ease debugging when the gate flips.
// eslint-disable-next-line no-console
console.error(result.stdout, result.stderr);
}
expect(result.status).toBe(0);
} finally {
rmSync(root, { recursive: true, force: true });
}
});
}
});