vitest.my-usage.config.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import path from "node:path";
  2. import { defineConfig } from "vitest/config";
  3. /**
  4. * my-usage 专项覆盖率配置
  5. *
  6. * 目的:
  7. * - 仅统计本次改动相关模块,避免把需要完整 Next/Redis/Bull 的重模块纳入全局阈值
  8. * - 对“只读 Key 自助查询”这类安全敏感接口设置更高覆盖率门槛(>= 80%)
  9. */
  10. export default defineConfig({
  11. test: {
  12. globals: true,
  13. environment: "node",
  14. setupFiles: ["./tests/setup.ts"],
  15. include: [
  16. "tests/api/my-usage-readonly.test.ts",
  17. "tests/api/api-actions-integrity.test.ts",
  18. "tests/integration/auth.test.ts",
  19. "tests/api/action-adapter-openapi.unit.test.ts",
  20. ],
  21. exclude: ["node_modules", ".next", "dist", "build", "coverage"],
  22. coverage: {
  23. provider: "v8",
  24. reporter: ["text", "html", "json"],
  25. reportsDirectory: "./coverage-my-usage",
  26. include: [
  27. "src/actions/my-usage.ts",
  28. "src/lib/auth.ts",
  29. "src/lib/api/action-adapter-openapi.ts",
  30. ],
  31. exclude: ["node_modules/", "tests/", "**/*.d.ts", ".next/"],
  32. thresholds: {
  33. lines: 80,
  34. functions: 80,
  35. branches: 70,
  36. statements: 80,
  37. },
  38. },
  39. reporters: ["verbose"],
  40. isolate: true,
  41. mockReset: true,
  42. restoreMocks: true,
  43. clearMocks: true,
  44. },
  45. resolve: {
  46. alias: {
  47. "@": path.resolve(__dirname, "./src"),
  48. "server-only": path.resolve(__dirname, "./tests/server-only.mock.ts"),
  49. },
  50. },
  51. });