vitest.config.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import tsconfigPaths from 'vite-tsconfig-paths'
  2. import { defineConfig } from 'vitest/config'
  3. export default defineConfig({
  4. // Vite ≥8 warns that this plugin can be replaced by the native (experimental)
  5. // `resolve.tsconfigPaths: true`. It cannot — keep the plugin. Tests run
  6. // unbuilt (see AGENTS.md): bare workspace names like `cordis` or
  7. // `@deepseek-ai/dsh-llm` must resolve to src/, and that mapping comes from
  8. // the root tsconfig.json paths map. The native option is a bare boolean:
  9. // for each
  10. // importing file it discovers the NEAREST tsconfig.json and applies that
  11. // file's own `paths`. Every workspace under packages/* and vendor/* has its
  12. // own tsconfig.json without `paths`, so native resolution maps nothing,
  13. // falls through to package.json exports (lib/, absent until `pnpm run build`),
  14. // and every test file fails to import (verified on vite 8.0.16 /
  15. // vitest 4.1.8). Making it work would mean copying the paths map into all
  16. // 15 workspace tsconfigs — including vendor/* ones, which are pinned
  17. // upstream copies (vendor/README.md). The plugin's `projects` option
  18. // instead applies the one root map to every importer.
  19. plugins: [tsconfigPaths({ projects: ['./tsconfig.json'] })],
  20. test: {
  21. include: ['packages/*/*/tests/**/*.spec.ts', 'examples/*/tests/**/*.spec.ts'],
  22. coverage: {
  23. provider: 'v8',
  24. // Coverage measures OUR runtime source. Types-only files carry no
  25. // executable code; vendor/ and examples/ are out of scope (examples are
  26. // exercised by the demo smoke test instead).
  27. include: ['packages/*/*/src/**/*.ts'],
  28. // Types-only files carry no executable code. `bin.ts` files are
  29. // self-executing CLI entrypoints (a top-level `await main()`): a spec
  30. // can't import one without booting it, so they are driven by the keyless
  31. // Loader-path smoke (a real subprocess) instead of the in-process unit
  32. // suite — the same reason `examples/start.ts` sat out of coverage scope.
  33. // `worker.ts` files are the same class as bin.ts: self-executing
  34. // worker-thread entrypoints that only ever run inside a spawned isolate
  35. // the v8 provider cannot observe. They stay thin glue over in-process-
  36. // tested logic (bootstrap.ts) and are pinned by real-worker integration
  37. // tests.
  38. exclude: ['packages/*/*/src/types.ts', 'packages/*/*/src/bin.ts', 'packages/*/*/src/worker.ts'],
  39. // 100% or it doesn't merge (docs/testing.md: excessive tests are welcome).
  40. // Per-file so a well-covered big file can't subsidize a bare one.
  41. // Every v8 ignore comment must carry a reason — see the quality-gates RFC
  42. // (docs/rfc/implemented/process/2026-06-11-quality-gates.md).
  43. thresholds: {
  44. perFile: true,
  45. statements: 100,
  46. branches: 100,
  47. functions: 100,
  48. lines: 100,
  49. },
  50. reporter: process.env.CI ? ['text'] : ['text', 'html'],
  51. },
  52. },
  53. })