import { defineConfig } from 'vitest/config';
import path from 'node:path';

export default defineConfig({
  test: {
    include: ['tests/**/*.test.ts'],
    globals: false,
    environment: 'node',
    // Tests that touch the DB pull a fresh schema into a temp file in a
    // beforeAll hook (see tests/helpers/db.ts). Single fork so distinct
    // test files don't trample each other on the same `app.db` path
    // resolution.
    pool: 'forks',
    forks: { singleFork: true },
    // Action tests need DATABASE_URL set + schema pushed before the
    // first prisma import in lib/prisma. setupFiles run before each
    // test file's imports.
    setupFiles: ['tests/helpers/setup-actions.ts'],
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, '.'),
    },
  },
});
