module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>/src'],
testMatch: ['**/__tests__/**/*.ts', '**/?(*.)+(spec|test).ts'],
transform: {
'^.+\\.ts$': 'ts-jest',
},
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.d.ts',
'!src/**/*.test.ts',
'!src/**/__tests__/**',
],
coverageDirectory: 'coverage',
coverageReporters: ['text', 'lcov', 'html'],
coverageThreshold: {
global: {
branches: 94,
functions: 95,
lines: 95,
statements: 95,
},
},
setupFilesAfterEnv: ['<rootDir>/src/test/setup.ts'],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
'^@commands/(.*)$': '<rootDir>/src/commands/$1',
'^@core/(.*)$': '<rootDir>/src/core/$1',
'^@infrastructure/(.*)$': '<rootDir>/src/infrastructure/$1',
'^@shared/(.*)$': '<rootDir>/src/shared/$1',
'^@test/(.*)$': '<rootDir>/src/test/$1',
},
// Prevent worker process warnings
maxWorkers: 1,
forceExit: true,
// Clear timers and mocks after each test
clearMocks: true,
restoreMocks: true,
// Timeout settings
testTimeout: 10000,
};