import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react';
import path from 'path';

export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      '@/': path.resolve(import.meta.dirname, 'src') + '/',
      '@meshitrack/shared': path.resolve(import.meta.dirname, '../shared/src'),
    },
    extensions: ['.ts', '.tsx', '.js', '.jsx'],
  },
  test: {
    globals: true,
    environment: 'jsdom',
    include: ['tests/**/*.test.{ts,tsx}'],
    setupFiles: ['./vitest.setup.ts'],
    css: false,
    coverage: {
      provider: 'v8',
      enabled: false,
      // @ts-expect-error -- v8 provider supports `all` but types lag behind
      all: true,
      include: ['src/**/*.{ts,tsx}'],
      exclude: [
        'src/test-utils.tsx',
        'src/app/layout.tsx',
        'src/app/api/**',
        'src/lib/auth.ts',
        'src/proxy.ts',
        'src/**/*.d.ts',
        'src/app/(dashboard)/layout.tsx',
        'src/app/login/**',
      ],
      reporter: ['text', 'lcov', 'json-summary', 'html'],
      reportsDirectory: './coverage',
      thresholds: {
        lines: 90,
        functions: 85,
        branches: 75,
        statements: 85,
      },
    },
    testTimeout: 10_000,
  },
});
