// vitest.config.integration.ts import { defineConfig, mergeConfig } from 'vitest/config'; import viteConfig from './vite.config'; /** * This configuration is specifically for integration tests. * It MERGES with the main vite.config.ts to inherit plugins and aliases, * then overrides the test-specific settings for a Node.js environment. */ export default mergeConfig(viteConfig, defineConfig({ test: { // Override settings from the main config for this specific test project. name: 'integration', environment: 'node', // The path must be specific. By default, Vitest doesn't look in `src` // unless the pattern explicitly includes it. include: ['src/**/*.integration.test.ts'], // CRITICAL: We must override the `exclude` property from the base vite.config.ts. // Otherwise, the inherited `exclude` rule will prevent any integration tests from running. // Setting it to an empty array removes all exclusion rules for this project. exclude: [], // This setup script starts the backend server before tests run. globalSetup: './src/tests/setup/integration-global-setup.ts', testTimeout: 15000, // Increased timeout for server startup and API calls. // "singleThread: true" is removed in modern Vitest. // Use fileParallelism: false to ensure test files run one by one to prevent port conflicts. fileParallelism: false, coverage: { provider: 'v8', // We remove 'text' here. The final text report will be generated by `nyc` after merging. reporter: ['html', 'json-summary', 'json'], reportsDirectory: '.coverage/integration', clean: true, }, } }));