vitest.config.ts 676 B

123456789101112131415161718192021222324252627
  1. import { defineConfig } from 'vitest/config';
  2. export default defineConfig({
  3. test: {
  4. globals: true,
  5. environment: 'node',
  6. include: ['tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
  7. coverage: {
  8. provider: 'v8',
  9. reporter: ['text', 'json', 'html'],
  10. exclude: [
  11. 'tests/**',
  12. '**/*.d.ts',
  13. '**/*.config.*',
  14. '**/dist/**'
  15. ]
  16. },
  17. // 关闭并行测试以避免数据库连接冲突
  18. fileParallelism: false,
  19. // 设置测试环境变量
  20. setupFiles: [],
  21. env: {
  22. NODE_ENV: 'test',
  23. TEST_DATABASE_URL: 'postgresql://postgres:test_password@localhost:5432/test_d8dai'
  24. }
  25. }
  26. });