import { defineConfig } from 'vitest/config';

export default defineConfig({
  // Repo-wide convention: React components live in .js files (Next.js
  // pages-router style — see AGENTS.md Gotcha #9, "typescript is a devDep
  // but the source is JavaScript-only"). Vite's default esbuild loader
  // treats .js as plain JS and rejects JSX, which breaks any test that
  // imports a component (e.g. test/components/Layout.test.js). This widens
  // the JSX loader to .js so component tests work without renaming files.
  esbuild: {
    loader: 'jsx',
    jsx: 'automatic',
    include: /\.[jt]sx?$/,
    exclude: [],
  },
  test: {
    environment: 'node',
    globals: false,
    setupFiles: ['./test/setup.js'],
    include: ['test/**/*.test.js'],
    testTimeout: 5000,
  },
});
