mike-backend / backend /src /lib /inference /frontendProjection.test.ts
bardd's picture
Deploy Mike backend-only Space
06671aa verified
Raw History Blame Contribute Delete
1.3 kB
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
import { spawnSync } from "node:child_process";
import test from "node:test";
const repoRoot = path.join(__dirname, "../../../..");
const generatedPath = path.join(
repoRoot,
"frontend/src/generated/inference-config.json",
);
const exportScript = path.join(
repoRoot,
"backend/scripts/export-inference-frontend-config.mjs",
);
function runExport(): void {
const result = spawnSync("node", [exportScript], {
cwd: path.join(repoRoot, "backend"),
encoding: "utf8",
});
assert.equal(
result.status,
0,
`frontend inference export failed: ${result.stderr || result.stdout}`,
);
}
test("frontend inference config matches the canonical manifest", () => {
const committed = fs.readFileSync(generatedPath, "utf8");
runExport();
assert.equal(
fs.readFileSync(generatedPath, "utf8"),
committed,
"run npm run export:inference-config and commit the generated artifact",
);
});
test("frontend inference config export is deterministic", () => {
runExport();
const first = fs.readFileSync(generatedPath, "utf8");
runExport();
assert.equal(fs.readFileSync(generatedPath, "utf8"), first);
});