vitest.config.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import tsconfigPaths from 'vite-tsconfig-paths'
  2. import { defineConfig } from 'vitest/config'
  3. const windowsUnsupportedPackages = process.platform === 'win32'
  4. ? [
  5. 'packages/bash/*',
  6. 'packages/hooks/*',
  7. 'packages/sandbox/sandbox-local',
  8. 'packages/sdk/create-sdk',
  9. 'packages/sdk/helper',
  10. ]
  11. : []
  12. export default defineConfig({
  13. // Native path resolution reads each package's nearest tsconfig, but only the root defines
  14. // workspace paths. Keep this plugin pinned to the root map so unbuilt bare package imports resolve
  15. // to source; native resolution would fall through to absent `lib/` outputs.
  16. plugins: [tsconfigPaths({ projects: ['./tsconfig.json'] })],
  17. test: {
  18. include: ['packages/*/*/tests/**/*.spec.ts', 'examples/*/tests/**/*.spec.ts', 'scripts/**/*.spec.ts'],
  19. exclude: windowsUnsupportedPackages.map(path => `${path}/tests/**/*.spec.ts`),
  20. coverage: {
  21. provider: 'v8',
  22. // Coverage measures OUR runtime source. Types-only files carry no
  23. // executable code; vendor/ and examples/ are out of scope (examples are
  24. // exercised by the demo smoke test instead).
  25. include: ['packages/*/*/src/**/*.ts'],
  26. // Types-only files have no runtime coverage. Importing self-executing bins/workers would boot
  27. // them inside the unit process, so real subprocess/Worker tests cover their thin entry glue.
  28. exclude: [
  29. 'packages/*/*/src/types.ts',
  30. 'packages/*/*/src/bin.ts',
  31. 'packages/*/*/src/worker.ts',
  32. ...windowsUnsupportedPackages.map(path => `${path}/src/**/*.ts`),
  33. ],
  34. // 100% or it doesn't merge (docs/testing.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 the quality-gates RFC
  37. // (docs/rfc/implemented/process/2026-06-11-quality-gates.md).
  38. thresholds: {
  39. perFile: true,
  40. statements: 100,
  41. branches: 100,
  42. functions: 100,
  43. lines: 100,
  44. },
  45. reporter: process.env.CI ? ['text'] : ['text', 'html'],
  46. },
  47. },
  48. })