1
0

vitest.config.ts 1.4 KB

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