import react from "@vitejs/plugin-react"
/// <reference types="vitest" />
import { defineConfig } from "vite"

export default defineConfig({
  plugins: [react()],
  // Suppress source map warnings (known Vite issue with test files)
  logLevel: "error",
  server: {
    proxy: {
      "/api": {
        target: "http://localhost:8000",
        changeOrigin: true,
      },
    },
  },
  test: {
    globals: true,
    environment: "jsdom",
    setupFiles: ["./src/test/setup.ts"],
    include: ["src/**/*.{test,spec}.{ts,tsx}"],
    // Suppress expected React error boundary messages in test output
    onConsoleLog(log) {
      if (
        log.includes("The above error occurred") ||
        log.includes("Error: Uncaught") ||
        log.includes("ComponentNotFoundError") ||
        log.includes("ExportNotFoundError") ||
        log.includes("InvalidComponentNameError")
      ) {
        return false
      }
    },
    coverage: {
      provider: "v8",
      reporter: ["text", "json", "html"],
      include: ["src/**/*.{ts,tsx}"],
      exclude: ["src/test/**", "src/main.tsx", "src/vite-env.d.ts"],
    },
  },
})
