import path from "node:path";
import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";

export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
  test: {
    // Node 18+ exposes `Response` / `fetch` globals, so we don't need jsdom.
    // VITE_API_BASE_URL must be set so the api module treats itself as
    // configured; otherwise every GET would throw notConfiguredError before
    // reaching the mocked fetch.
    env: {
      VITE_API_BASE_URL: "http://test.local",
    },
    // Skip sibling worktrees + their node_modules so each worktree only runs
    // its own tests. Without this, vitest walks up the tree and re-runs the
    // main checkout's tests from inside the worktree, inflating the count.
    exclude: [
      "**/node_modules/**",
      "**/dist/**",
      ".worktrees/**",
    ],
  },
});
