jest.config.js•1.46 kB
/** @type {import('jest').Config} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
transform: {
'^.+\.tsx?$': ['ts-jest', {
// Use isolated modules to improve performance
isolatedModules: true,
// Disable TypeScript type checking during tests to focus on functionality
transpileOnly: true,
// Configure diagnostics for better error messages
diagnostics: {
warnOnly: true,
ignoreCodes: [
'TS151001', // Cannot find module
'TS2571', // Object is of type 'unknown'
'TS2339', // Property does not exist on type
'TS7006', // Parameter implicitly has an 'any' type
],
},
}],
},
// Configure test setup files
setupFilesAfterEnv: ['./src/__tests__/setupTests.ts'],
// Test patterns
testMatch: ['**/__tests__/**/*.test.ts'],
// Exclude obsolete tests
testPathIgnorePatterns: ['<rootDir>/src/__tests__/obsolete/'],
// Mock all modules
automock: false,
// Clear mocks before each test
clearMocks: true,
// Timeout for tests (in milliseconds)
testTimeout: 10000,
// Max workers
maxWorkers: '50%',
// Force exit after tests complete
forceExit: true,
roots: ['<rootDir>/src'],
coverageDirectory: 'coverage',
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.d.ts',
'!src/**/__tests__/**',
'!**/node_modules/**',
],
moduleFileExtensions: ['ts', 'js', 'json', 'node'],
};