vitest.config.mts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { defineConfig } from 'vitest/config';
  2. /**
  3. * The SHARED base. `vitest.workspace.mts` extends it twice — once for the
  4. * engine's node-environment suites and once for the viewer package's jsdom
  5. * one — so the environment, the plugins and the module-resolution conditions
  6. * a browser test needs cannot leak into the other 200-odd suites.
  7. */
  8. export default defineConfig({
  9. test: {
  10. globals: true,
  11. environment: 'node',
  12. include: ['__tests__/**/*.test.ts'],
  13. /**
  14. * Several MCP integration tests (mcp-daemon, mcp-initialize, mcp-ppid-watchdog,
  15. * mcp-roots) spawn `dist/bin/codegraph.js serve --mcp` with `process.execPath`
  16. * and rely on the child inheriting `process.env`. On a Node >= 25 dev machine
  17. * the CLI's hard-block (src/bin/codegraph.ts) would otherwise exit the child
  18. * before it ever responds, so every spawn-based test times out — see #478.
  19. *
  20. * Setting the override here keeps the CLI's runtime guard intact for end
  21. * users (it's still enforced when `codegraph` is invoked directly) while
  22. * letting the test suite run on whatever Node the contributor happens to
  23. * have installed. CI on Node 22/23 is unaffected — the guard doesn't fire
  24. * there, so the variable is a no-op.
  25. */
  26. env: {
  27. CODEGRAPH_ALLOW_UNSAFE_NODE: '1',
  28. /**
  29. * The suite spawns real CLI/MCP processes; without this they would write
  30. * telemetry state into the contributor's real ~/.codegraph and count test
  31. * tool calls as real usage. The telemetry unit tests are unaffected —
  32. * they inject their own `env` via the Telemetry constructor.
  33. */
  34. CODEGRAPH_TELEMETRY: '0',
  35. },
  36. coverage: {
  37. provider: 'v8',
  38. reporter: ['text', 'json', 'html'],
  39. },
  40. },
  41. });