test(generators): e2e byte-identical reconstruction of core-realtime

This commit is contained in:
2026-05-09 13:33:53 +02:00
parent 4308762caa
commit e28fe847fd
2 changed files with 25 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
import { describe, it, expect } from "vitest";
import { mkdtempSync, cpSync, readFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { execSync } from "node:child_process";
import { join } from "node:path";
import { computeSnapshot } from "../lib/snapshot";
import expectedSnapshot from "../__snapshots__/core-package/realtime.snapshot.json";
describe("e2e: core-package realtime", () => {
it("byte-identical reconstruction matches snapshot", { timeout: 120_000 }, () => {
const tmp = mkdtempSync(join(tmpdir(), "e2e-"));
cpSync(process.cwd(), tmp, {
recursive: true,
filter: (src) =>
!src.includes("node_modules") &&
!src.includes(".turbo") &&
!src.includes("packages/core-realtime"),
});
execSync(`cd ${tmp} && pnpm install --frozen-lockfile=false`, { stdio: "ignore" });
execSync(`cd ${tmp} && pnpm turbo gen core-package --args realtime`, { stdio: "ignore" });
const result = computeSnapshot(join(tmp, "packages/core-realtime"));
expect(result).toEqual(expectedSnapshot);
});
});

View File

@@ -4,7 +4,7 @@ export default defineConfig({
test: {
globals: true,
environment: "node",
include: ["*.test.ts", "lib/*.test.ts"],
include: ["*.test.ts", "lib/*.test.ts", "__tests__/*.test.ts"],
clearMocks: true,
restoreMocks: true,
},