jest.config.js•1.34 kB
/**
* Jest Configuration
* Configures Jest for unit testing with TypeScript support
*/
module.exports = {
// Test environment
testEnvironment: 'node',
// File extensions to test
moduleFileExtensions: ['js', 'ts', 'json'],
// Transform files
transform: {
'^.+\\.ts$': 'ts-jest',
},
// Test file patterns
testMatch: [
'**/__tests__/**/*.test.ts',
'**/?(*.)+(spec|test).ts'
],
// Coverage configuration
collectCoverage: true,
coverageDirectory: 'coverage',
coverageReporters: ['text', 'lcov', 'html'],
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.d.ts',
'!src/**/*.test.ts',
'!src/**/__tests__/**',
'!src/**/index.ts'
],
// Coverage thresholds
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80
}
},
// Setup files
setupFilesAfterEnv: ['<rootDir>/src/__tests__/setup.ts'],
// Module name mapping for imports
moduleNameMapping: {
'^@/(.*)$': '<rootDir>/src/$1'
},
// Clear mocks between tests
clearMocks: true,
// Restore mocks after each test
restoreMocks: true,
// Verbose output
verbose: true,
// Test timeout
testTimeout: 10000,
// Globals for TypeScript
globals: {
'ts-jest': {
tsconfig: 'tsconfig.json'
}
}
};