Files
flyer-crawler.projectium.com/vitest.config.integration.ts
Torben Sorensen 27bcc8c028
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 38m14s
we went to mocks - now going to unit-setup.ts - centralized
2025-11-26 17:53:34 -08:00

56 lines
2.7 KiB
TypeScript

// vitest.config.integration.ts
import { defineConfig, mergeConfig } from 'vitest/config';
import viteConfig from './vite.config';
// 1. Separate the 'test' config (which has Unit Test exclusions)
// from the rest of the general Vite config (plugins, aliases, etc.)
// We cast to 'any' to avoid strict type checking on the import if necessary.
// DEBUG: Use console.error to ensure logs appear in CI/CD output
console.error('[DEBUG] Loading vitest.config.integration.ts...');
const { test: _unusedTest, ...baseViteConfig } = viteConfig as any;
console.error('\n[DEBUG] --- INTEGRATION CONFIG SETUP ---');
// Use _unusedTest to satisfy linter
console.error(`[DEBUG] Stripped "test" config. Original test config existed: ${!!_unusedTest}`);
// Use the 'in' operator for a type-safe property check instead of casting to 'any'.
console.error('[DEBUG] Does baseViteConfig have "test"?', 'test' in baseViteConfig);
/**
* 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.
*/
const finalConfig = mergeConfig(baseViteConfig, defineConfig({
test: {
// Override settings from the main config for this specific test project.
name: 'integration',
environment: 'node',
// Point specifically to the new integration tests directory.
// This pattern will match any test file inside `src/tests/integration/`.
include: ['src/tests/integration/**/*.test.{ts,tsx}'],
// 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: 60000, // Increased timeout for server startup and API calls, especially AI services.
// "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,
},
}
}));
console.error('[DEBUG] Integration Final Config - INCLUDE:', finalConfig.test?.include);
console.error('[DEBUG] Integration Final Config - EXCLUDE:', finalConfig.test?.exclude);
console.error('[DEBUG] ----------------------------------\n');
export default finalConfig;