Skip to Content

Testing

Setup (Vitest)

Tests run on Vitest  configured in vitest.config.ts:

export default defineConfig({ plugins: [react(), tsconfigPaths()], test: { environment: "jsdom", globals: true, setupFiles: ["./vitest.setup.ts"], include: ["src/**/*.{test,spec}.{ts,tsx}"], coverage: { provider: "v8", reporter: ["text", "html"], include: ["src/**/*.{ts,tsx}"], exclude: ["src/**/*.{test,spec}.{ts,tsx}", "src/**/*.d.ts"], }, }, });

vitest.setup.ts pulls in @testing-library/jest-dom/vitest for DOM matchers. The react and tsconfig-paths Vite plugins give component tests JSX support and @/ path-alias resolution. The jsdom environment lets UI code run without a browser. Test files live next to the code they cover as *.test.ts(x) / *.spec.ts(x) under src/.

Running

npm test # vitest run — single pass (CI mode) npm run test:watch # vitest — watch mode npm run test:coverage # vitest run --coverage — v8 coverage, text + html reports

What’s covered

The Vitest suite covers the pure engines (registry, domain model, rules, drift, cost, merge, overlays, relationship classes), IaC import/export plus fidelity, the multi-cloud discovery transforms for AWS/GCP/Azure and their /api/discover routes, local version-history snapshots, the MCP importer and the running MCP server, the canvas helpers (geometry, layout, arrange, navGrid, image export), persistence (localStore, the file repository, graph schema), the graphs API route, and UI/hook/accessibility tests (the Palette, the store/history/interaction hooks, and the dialog-a11y hook). src/server/graphSchema.test.ts exercises the runtime shape validators in src/server/graphSchema.ts (hasGraphCollections, isInfrastructureGraph) — the boundary checks that guard request bodies and on-disk JSON before they are treated as an InfrastructureGraph.

Validators as CI guardrails

Two validators are the first line of defence, and both are exercised by the suite that runs in CI:

  • validateRegistry() (src/aws/registry.ts) — catches duplicate service ids, unknown categories, dangling commonConnections targets, and cfnType collisions. It runs at module load and is asserted directly in src/aws/registry.test.ts, which fails the build on any error-level issue (“returns NO error-level issues — CI integrity guardrail”).
  • validateGraph() (src/aws/model.ts) — catches duplicate resource ids, parentIds pointing at missing resources, and relationships referencing missing endpoints. It runs on every API write and is covered by the model and route tests.

CI itself lives in .github/workflows/ci.yml: it runs typecheck, lint, format:check, test:coverage (which includes registry.test.ts), and build on every push/PR, so a registry regression breaks the build. See Roadmap → Recently shipped.

Last updated on