vitest.e2e.config.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import tsconfigPaths from 'vite-tsconfig-paths'
  2. import { defineConfig } from 'vitest/config'
  3. // Real-API end-to-end tests: `pnpm run test:e2e`, file pattern *.e2e.ts.
  4. // Separate from the default suite (`pnpm run test`, *.spec.ts) on purpose —
  5. // these hit the live DeepSeek API, spend tokens, and need a key.
  6. //
  7. // Secrets: tests gate themselves with
  8. // `describe.skipIf(!process.env.DEEPSEEK_API_KEY)`, so the suite passes
  9. // (all-skipped) without credentials — CI has none and stays green. Put the
  10. // key in the environment or in a gitignored `.env` at the repo root:
  11. //
  12. // DEEPSEEK_API_KEY=sk-…
  13. // DEEPSEEK_BASE_URL=https://… # optional, defaults to the public API
  14. try {
  15. // Node >= 21.7 native; throws when the file does not exist.
  16. process.loadEnvFile(new URL('.env', import.meta.url).pathname)
  17. } catch {
  18. // No .env — fine, the environment may already carry the variables.
  19. }
  20. export default defineConfig({
  21. // Same resolution note as vitest.config.ts: bare workspace names resolve
  22. // through the root tsconfig paths map; the native option cannot do this.
  23. plugins: [tsconfigPaths({ projects: ['./tsconfig.json'] })],
  24. test: {
  25. include: ['packages/*/*/tests/**/*.e2e.ts', 'examples/*/tests/**/*.e2e.ts'],
  26. // Real model calls: generous timeouts, and retries for transient flakes
  27. // (the shared internal key hits concurrency quotas). No coverage — the
  28. // unit suites own the coverage gate.
  29. testTimeout: 120_000,
  30. hookTimeout: 30_000,
  31. retry: 2,
  32. // Run e2e files one at a time: the shared internal API key has a small
  33. // concurrency quota, and parallel files issue enough simultaneous requests
  34. // to trip it (manifesting as flaky rate-limit errors).
  35. fileParallelism: false,
  36. },
  37. })