vitest.integration.config.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import path from "node:path";
  2. import { defineConfig } from "vitest/config";
  3. export default defineConfig({
  4. test: {
  5. globals: true,
  6. environment: "node",
  7. setupFiles: ["./tests/setup.ts"],
  8. api: {
  9. host: process.env.VITEST_API_HOST || "127.0.0.1",
  10. port: Number(process.env.VITEST_API_PORT || 51204),
  11. strictPort: false,
  12. },
  13. open: false,
  14. testTimeout: 20000,
  15. hookTimeout: 20000,
  16. maxConcurrency: 5,
  17. pool: "threads",
  18. // 仅运行"需要数据库"的集成测试(避免把所有重依赖测试默认跑进 CI)
  19. // 说明:包括 tests/integration/ 目录和从主配置排除的需要 DB 的 API 测试
  20. include: [
  21. "tests/integration/webhook-targets-crud.test.ts",
  22. "tests/integration/notification-bindings.test.ts",
  23. "tests/integration/auth.test.ts",
  24. "tests/integration/provider-endpoint-sync-race.test.ts",
  25. "tests/integration/provider-endpoint-regression-742.test.ts",
  26. // 需要 DB 的 API 测试(从主配置排除,在此运行)
  27. "tests/api/users-actions.test.ts",
  28. "tests/api/providers-actions.test.ts",
  29. "tests/api/keys-actions.test.ts",
  30. "tests/api/my-usage-readonly.test.ts",
  31. ],
  32. exclude: ["node_modules", ".next", "dist", "build", "coverage", "**/*.d.ts"],
  33. reporters: ["verbose"],
  34. isolate: true,
  35. mockReset: true,
  36. restoreMocks: true,
  37. clearMocks: true,
  38. resolveSnapshotPath: (testPath, snapExtension) => {
  39. return testPath.replace(/\.test\.([tj]sx?)$/, `${snapExtension}.$1`);
  40. },
  41. },
  42. resolve: {
  43. alias: {
  44. "@": path.resolve(__dirname, "./src"),
  45. "server-only": path.resolve(__dirname, "./tests/server-only.mock.ts"),
  46. },
  47. },
  48. });