import { readFile } from "node:fs/promises"; import { describe, expect, it } from "vitest"; import { architectureDependencyReportArtifactSchema } from "../../scripts/contracts/release-artifacts.ts"; // 12-05 (D-11). dependency-cruiser cannot parse TypeScript 7, so it checked // zero modules and passed while its report claimed a result. The import graph // in check-architecture.ts is the only checker; the report carries only it. const staticImportGraph = { analyzer: "babel-parser-node-resolver", modules: [], dependencies: [], unresolved: [], parseFailures: [], cycles: [], violations: [], summary: { modules: 0, typescriptModules: 0, dependencies: 0, localDependencies: 0, unresolved: 0, parseFailures: 0, cycles: 0, errors: 0, typeScriptOnlyPolicyPassed: true, nonTypeScriptExecutableSources: 0, }, fixtureChecks: { passed: true, checks: [], failures: [] }, typeScriptOnlySourcePolicy: { checkedRoots: ["src"], exceptionsAllowed: false, violations: [], passed: true, }, }; describe("architecture dependency report", () => { it("carries the import graph only", () => { expect(architectureDependencyReportArtifactSchema.parse({ staticImportGraph })).toEqual({ staticImportGraph, }); }); it("rejects a dependency-cruiser section", () => { const cruiserSummary = { violations: [], error: 0, warn: 0, info: 0, ignore: 0, totalCruised: 0, totalDependenciesCruised: 0, }; expect( architectureDependencyReportArtifactSchema.safeParse({ modules: [], summary: cruiserSummary, staticImportGraph, }).success, ).toBe(false); }); it("does not run dependency-cruiser", async () => { expect(await readFile("scripts/check-architecture.ts", "utf8")).not.toMatch(/depcruise/u); }); });