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

const __dirname = path.dirname(fileURLToPath(import.meta.url));

export default defineConfig({
  plugins: [react()],
  test: {
    globals: true,
    environment: 'jsdom',
    setupFiles: ['./app/test/setup.ts'],
    coverage: {
      provider: 'v8',
      reporter: ['text', 'json', 'html'],
      exclude: [
        'node_modules/',
        'app/test/',
        '**/*.test.{ts,tsx}',
        '**/*.spec.{ts,tsx}',
        '**/types.ts',
      ],
    },
  },
  resolve: {
    alias: [
      { find: /^~\/database\/(.*)$/, replacement: path.resolve(__dirname, './database/$1') },
      { find: /^~\/server\/(.*)$/, replacement: path.resolve(__dirname, './server/$1') },
      { find: /^~\/(.*)$/, replacement: path.resolve(__dirname, './app/$1') },
      { find: /^@\/(.*)$/, replacement: path.resolve(__dirname, './app/$1') },
      { find: 'app', replacement: path.resolve(__dirname, './app') },
    ],
  },
});
