vitest.usage-logs-sessionid-search.config.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import path from "node:path";
  2. import { defineConfig } from "vitest/config";
  3. /**
  4. * Dashboard Logs(Session ID 搜索:前缀匹配 + LIKE 转义)专项覆盖率配置
  5. *
  6. * 目的:
  7. * - 仅统计本需求可隔离模块的覆盖率(>= 90%)
  8. * - 同时执行关联单测集合,避免只跑“指标好看”的子集
  9. */
  10. export default defineConfig({
  11. test: {
  12. globals: true,
  13. environment: "happy-dom",
  14. setupFiles: ["./tests/setup.ts"],
  15. include: [
  16. "tests/unit/repository/usage-logs-sessionid-suggestions.test.ts",
  17. "tests/unit/repository/usage-logs-sessionid-filter.test.ts",
  18. "tests/unit/repository/warmup-stats-exclusion.test.ts",
  19. "tests/unit/repository/escape-like.test.ts",
  20. "tests/unit/lib/constants/usage-logs.constants.test.ts",
  21. "tests/unit/lib/utils/clipboard.test.ts",
  22. ],
  23. exclude: ["node_modules", ".next", "dist", "build", "coverage", "tests/integration/**"],
  24. coverage: {
  25. provider: "v8",
  26. reporter: ["text", "html", "json", "lcov"],
  27. reportsDirectory: "./coverage-usage-logs-sessionid-search",
  28. include: [
  29. "src/repository/_shared/like.ts",
  30. "src/lib/constants/usage-logs.constants.ts",
  31. "src/lib/utils/clipboard.ts",
  32. ],
  33. exclude: ["node_modules/", "tests/", "**/*.d.ts", ".next/"],
  34. thresholds: {
  35. lines: 90,
  36. functions: 90,
  37. branches: 90,
  38. statements: 90,
  39. },
  40. },
  41. reporters: ["verbose"],
  42. isolate: true,
  43. mockReset: true,
  44. restoreMocks: true,
  45. clearMocks: true,
  46. },
  47. resolve: {
  48. alias: {
  49. "@": path.resolve(__dirname, "./src"),
  50. "server-only": path.resolve(__dirname, "./tests/server-only.mock.ts"),
  51. },
  52. },
  53. });