jest.config.jsโข1.6 kB
/** @type {import('jest').Config} */
module.exports = {
// Use ts-jest preset for TypeScript support
preset: 'ts-jest/presets/default-esm',
// Test environment
testEnvironment: 'node',
// Enable ESM support
extensionsToTreatAsEsm: ['.ts'],
// Module name mapping for ESM imports
moduleNameMapping: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
// Transform configuration
transform: {
'^.+\\.ts$': ['ts-jest', {
useESM: true,
tsconfig: {
module: 'ESNext',
moduleResolution: 'node'
}
}]
},
// Test file patterns
testMatch: [
'**/tests/**/*.test.ts',
'**/__tests__/**/*.test.ts'
],
// Test roots
roots: ['<rootDir>/src', '<rootDir>/tests'],
// Ignore patterns
testPathIgnorePatterns: [
'/node_modules/',
'/dist/',
'/build/'
],
// Coverage configuration
collectCoverage: true,
coverageDirectory: 'coverage',
coverageReporters: [
'text',
'lcov',
'html',
'json-summary'
],
// Coverage collection patterns
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.d.ts',
'!src/**/*.test.ts',
'!src/**/__tests__/**',
'!src/types.ts'
],
// Coverage thresholds
coverageThreshold: {
global: {
branches: 70,
functions: 70,
lines: 70,
statements: 70
}
},
// Test timeout
testTimeout: 30000,
// Verbose output
verbose: true,
// Clear mocks between tests
clearMocks: true,
// Restore mocks after each test
restoreMocks: true,
// Module file extensions
moduleFileExtensions: ['ts', 'js', 'json', 'node']
};