vitest.config.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. exclude: ['packages/*/*/src/types.ts', 'packages/*/*/src/bin.ts'],
  34. // 100% or it doesn't merge (AGENTS.md: excessive tests are welcome).
  35. // Per-file so a well-covered big file can't subsidize a bare one.
  36. // Every v8 ignore comment must carry a reason — see AGENTS.md.
  37. thresholds: {
  38. perFile: true,
  39. statements: 100,
  40. branches: 100,
  41. functions: 100,
  42. lines: 100,
  43. },
  44. reporter: ['text', 'html'],
  45. },
  46. },
  47. })