vitest.proxy-guard-pipeline.config.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import path from "node:path";
  2. import { defineConfig } from "vitest/config";
  3. /**
  4. * Proxy GuardPipeline 专项覆盖率配置
  5. *
  6. * 目的:
  7. * - 针对 /v1/chat/completions 与 /v1/responses 的 GuardPipeline 接入做强约束
  8. * - 只统计本次相关模块,避免把需要完整 Next/DB/Redis 的重模块纳入阈值
  9. * - 覆盖率阈值:>= 90%
  10. */
  11. export default defineConfig({
  12. test: {
  13. globals: true,
  14. environment: "happy-dom",
  15. setupFiles: ["./tests/setup.ts"],
  16. include: [
  17. "tests/unit/proxy/chat-completions-handler-guard-pipeline.test.ts",
  18. "tests/unit/proxy/guard-pipeline-warmup.test.ts",
  19. ],
  20. exclude: ["node_modules", ".next", "dist", "build", "coverage", "tests/integration/**"],
  21. coverage: {
  22. provider: "v8",
  23. reporter: ["text", "html", "json"],
  24. reportsDirectory: "./coverage-proxy-guard-pipeline",
  25. include: [
  26. "src/app/v1/_lib/codex/chat-completions-handler.ts",
  27. "src/app/v1/_lib/proxy/guard-pipeline.ts",
  28. ],
  29. exclude: ["node_modules/", "tests/", "**/*.d.ts", ".next/"],
  30. thresholds: {
  31. lines: 90,
  32. functions: 90,
  33. branches: 90,
  34. statements: 90,
  35. },
  36. },
  37. reporters: ["verbose"],
  38. isolate: true,
  39. mockReset: true,
  40. restoreMocks: true,
  41. clearMocks: true,
  42. },
  43. resolve: {
  44. alias: {
  45. "@": path.resolve(__dirname, "./src"),
  46. "server-only": path.resolve(__dirname, "./tests/server-only.mock.ts"),
  47. },
  48. },
  49. });