import { defineConfig } from 'vitest/config'
import { resolve } from 'path'

export default defineConfig({
  test: {
    globals: true,
    environment: 'node',
    include: [
      'tests/unit/**/*.test.{ts,js}',
      'tests/integration/**/*.test.{ts,js}'
    ],
    exclude: [
      '**/node_modules/**',
      '**/dist/**',
      '**/build/**',
      '**/coverage/**'
    ],
    alias: {
      '@': resolve(__dirname, './src'),
    },
    testTimeout: 10000,
    setupFiles: ['./tests/utils/setup.ts'],
    // 覆盖率配置
    coverage: {
      provider: 'v8',
      reporter: ['text', 'lcov', 'html'],
      reportsDirectory: './coverage',
      exclude: [
        '**/node_modules/**',
        '**/dist/**',
        '**/build/**',
        '**/coverage/**',
        '**/*.d.ts',
        'tests/**',
        'scripts/**',
        '**/index.ts',
        '**/types.ts',
        'vitest.config.ts',
        'data-source.ts'
      ],
      thresholds: {
        branches: 65,
        functions: 65,
        lines: 65,
        statements: 65
      }
    },
    // 关闭并行测试以避免数据库连接冲突
    fileParallelism: false
  },
})