import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
// Test environment
environment: 'node',
// Global test configuration
globals: true,
// Test file patterns
include: [
'tests/**/*.test.ts',
'tests/**/*.spec.ts',
'tests/**/*.perf.test.ts'
],
exclude: [
'tests/legacy/**',
'node_modules/**',
'dist/**',
// Temporarily exclude slow/problematic tests
'tests/real-integration/**/*.test.ts',
'tests/integration/workflows/indexing-real-data.test.ts',
// Skip downloading model tests
'tests/integration/onnx-model-bridge.test.ts',
'tests/integration/services/python-embeddings.test.ts',
'tests/infrastructure/embeddings/onnx/onnx-cache-path.test.ts',
'tests/infrastructure/embeddings/onnx/onnx.tmoat.test.ts'
],
// Reporter configuration - using default reporter with summary disabled to match basic
reporters: process.env.CI ? ['junit'] : [['default', { summary: false }]],
outputFile: process.env.CI ? 'test-results.xml' : undefined,
// Memory-safe timeout settings
testTimeout: 20000, // 20 seconds
hookTimeout: 10000, // 10 seconds
// Coverage configuration
coverage: {
provider: 'v8',
reporter: ['text', 'html', 'json'],
exclude: [
'tests/**',
'dist/**',
'node_modules/**',
'**/*.d.ts',
'**/*.config.*'
],
thresholds: {
global: {
branches: 70, // Reduced from 80 for memory optimization
functions: 70,
lines: 70,
statements: 70
}
}
},
// No worker pools - run everything in main process for stability
// This eliminates IPC issues while maintaining Node.js API compatibility
// Test sequencing for memory safety
sequence: {
concurrent: false, // Disable concurrent execution
shuffle: false,
hooks: 'stack' // Run hooks in stack order
},
// Memory management settings
maxConcurrency: 1, // Run tests one at a time
fileParallelism: false, // Don't run test files in parallel
isolate: true, // Isolate tests to prevent memory leaks
retry: 1, // Reduced retries to avoid memory accumulation
// Trigger settings
forceRerunTriggers: [
'**/package.json',
'**/vitest.config.*',
'**/test-setup.*'
],
// Mock configuration
clearMocks: true,
restoreMocks: true,
// File watching disabled for memory safety
watch: false,
// Custom matchers and setup
setupFiles: ['tests/helpers/setup.ts']
},
// Define custom test configurations
define: {
__TEST_ENV__: JSON.stringify(process.env.NODE_ENV || 'test')
}
});