vitest.e2e.config.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import tsconfigPaths from 'vite-tsconfig-paths'
  2. import { defineConfig } from 'vitest/config'
  3. // Real-API suite, separate because it spends tokens. Each test self-skips without
  4. // DEEPSEEK_API_KEY for keyless CI; the credentialed workflow preflights the secret. Values may come
  5. // from the environment or gitignored root `.env`, with optional DEEPSEEK_BASE_URL.
  6. try {
  7. // Node >= 21.7 native; throws when the file does not exist.
  8. process.loadEnvFile(new URL('.env', import.meta.url).pathname)
  9. } catch {
  10. // No .env — fine, the environment may already carry the variables.
  11. }
  12. const DEFAULT_E2E_MAX_WORKERS = 4
  13. function positiveIntFromEnv(name: string, fallback: number): number {
  14. const raw = process.env[name]
  15. if (raw === undefined || raw === '') return fallback
  16. const value = Number(raw)
  17. if (!Number.isInteger(value) || value < 1) {
  18. throw new Error(`${name} must be a positive integer, got ${JSON.stringify(raw)}`)
  19. }
  20. return value
  21. }
  22. const e2eMaxWorkers = positiveIntFromEnv('DSH_E2E_MAX_WORKERS', DEFAULT_E2E_MAX_WORKERS)
  23. export default defineConfig({
  24. // Same resolution note as vitest.config.ts: bare workspace names resolve
  25. // through the root tsconfig paths map; the native option cannot do this.
  26. plugins: [tsconfigPaths({ projects: ['./tsconfig.json'] })],
  27. test: {
  28. include: ['packages/*/*/tests/**/*.e2e.ts', 'examples/*/tests/**/*.e2e.ts'],
  29. // Real model calls: generous timeouts, and retries for transient flakes
  30. // (the shared internal key hits concurrency quotas). No coverage — the
  31. // unit suites own the coverage gate.
  32. testTimeout: 120_000,
  33. hookTimeout: 30_000,
  34. retry: 2,
  35. // Run files in a bounded pool: enough lower-level parallelism to keep CI
  36. // and local with-key runs moving, while leaving a resource knob for shared
  37. // API quotas (`DSH_E2E_MAX_WORKERS=1` restores serial execution).
  38. fileParallelism: e2eMaxWorkers > 1,
  39. maxWorkers: e2eMaxWorkers,
  40. },
  41. })