import { fileURLToPath } from "node:url";

import { defineConfig } from "vitest/config";

/**
 * Database integration tests: `npm run test:db`. They run against the
 * database in `.env.test.local` (must end in "_test") and wipe it first.
 */
export default defineConfig({
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
      // The real package throws outside React Server Components.
      "server-only": fileURLToPath(
        new URL("./test/server-only-stub.ts", import.meta.url),
      ),
    },
  },
  test: {
    environment: "node",
    include: ["src/**/*.integration.test.ts"],
    // One database: run test files one after another.
    fileParallelism: false,
    testTimeout: 20_000,
    hookTimeout: 60_000,
  },
});
