1- import * as TJestConfigPkg from 'jest-config'
2-
31import { rootLogger } from '../util/logger'
42
5- import { getJestConfigPkg } from './jest-config-resolver'
6-
73const logger = rootLogger . child ( { namespace : 'jest-preset' } )
84
9- const jestConfigPkg : typeof TJestConfigPkg = getJestConfigPkg ( logger )
10-
11- const defaults = jestConfigPkg . defaults
12-
135export interface TsJestPresets {
146 transform : Record < string , string >
15- testMatch : string [ ] | undefined
16- moduleFileExtensions : string [ ] | undefined
7+ testMatch ? : string [ ]
8+ moduleFileExtensions ? : string [ ]
179}
1810
1911export interface CreateJestPresetOptions {
@@ -22,16 +14,15 @@ export interface CreateJestPresetOptions {
2214
2315export function createJestPreset (
2416 { allowJs = false } : CreateJestPresetOptions = { } ,
25- from ? : jest . InitialOptions ,
17+ from : jest . InitialOptions = { } ,
2618) : TsJestPresets {
2719 logger . debug ( { allowJs } , 'creating jest presets' , allowJs ? 'handling' : 'not handling' , 'JavaScript files' )
28- from = { ...defaults , ...from }
2920 return {
3021 transform : {
3122 ...from . transform ,
3223 [ allowJs ? '^.+\\.[tj]sx?$' : '^.+\\.tsx?$' ] : 'ts-jest' ,
3324 } ,
34- testMatch : from . testMatch || undefined ,
35- moduleFileExtensions : from . moduleFileExtensions || undefined ,
25+ ... ( from . testMatch ? { testMatch : from . testMatch } : undefined ) ,
26+ ... ( from . moduleFileExtensions ? { moduleFileExtensions : from . moduleFileExtensions } : undefined ) ,
3627 }
3728}
0 commit comments