@@ -86,8 +86,25 @@ export class TsJestTransformer implements SyncTransformer {
8686 this . _watchMode = ccs . watchMode
8787 configSet = ccs . configSet
8888 } else {
89+ if ( config . globals ?. [ 'ts-jest' ] ) {
90+ this . _logger . warn ( Deprecations . GlobalsTsJestConfigOption )
91+ }
92+ const jestGlobalsConfig = config . globals ?? { }
93+ const tsJestGlobalsConfig = jestGlobalsConfig [ 'ts-jest' ] ?? { }
94+ const migratedConfig = this . tsJestConfig
95+ ? {
96+ ...config ,
97+ globals : {
98+ ...jestGlobalsConfig ,
99+ 'ts-jest' : {
100+ ...tsJestGlobalsConfig ,
101+ ...this . tsJestConfig ,
102+ } ,
103+ } ,
104+ }
105+ : config
89106 // try to look-it up by stringified version
90- const serializedJestCfg = stringify ( config )
107+ const serializedJestCfg = stringify ( migratedConfig )
91108 const serializedCcs = TsJestTransformer . _cachedConfigSets . find (
92109 ( cs ) => cs . jestConfig . serialized === serializedJestCfg ,
93110 )
@@ -105,24 +122,6 @@ export class TsJestTransformer implements SyncTransformer {
105122 } else {
106123 // create the new record in the index
107124 this . _logger . info ( 'no matching config-set found, creating a new one' )
108-
109- if ( config . globals ?. [ 'ts-jest' ] ) {
110- this . _logger . warn ( Deprecations . GlobalsTsJestConfigOption )
111- }
112- const jestGlobalsConfig = config . globals ?? { }
113- const tsJestGlobalsConfig = jestGlobalsConfig [ 'ts-jest' ] ?? { }
114- const migratedConfig = this . tsJestConfig
115- ? {
116- ...config ,
117- globals : {
118- ...jestGlobalsConfig ,
119- 'ts-jest' : {
120- ...tsJestGlobalsConfig ,
121- ...this . tsJestConfig ,
122- } ,
123- } ,
124- }
125- : config
126125 configSet = this . _createConfigSet ( migratedConfig )
127126 const jest = { ...migratedConfig }
128127 // we need to remove some stuff from jest config
0 commit comments