Skip to content

Commit

Permalink
Merge pull request #3981 from ahnpnl/fix/revert-3966
Browse files Browse the repository at this point in the history
fix: revert #3966
  • Loading branch information
kulshekhar committed Jan 13, 2023
2 parents 3e49bd7 + 185eb18 commit 4e0623b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 28 deletions.
10 changes: 0 additions & 10 deletions src/legacy/ts-jest-transformer.spec.ts
Expand Up @@ -80,16 +80,6 @@ describe('TsJestTransformer', () => {
expect(cs2).toBe(cs1)
})

test('should return different config set for different tsJestConfig', () => {
const obj2 = { ...obj1, config: { ...obj1.config } }
// @ts-expect-error testing purpose
const cs1 = new TsJestTransformer({ isolatedModules: true })._configsFor(obj1)
// @ts-expect-error testing purpose
const cs2 = new TsJestTransformer({ isolatedModules: false })._configsFor(obj2)

expect(cs2).not.toBe(cs1)
})

test(`should not read disk cache with isolatedModules true`, () => {
const tr = new TsJestTransformer()
const cs = createConfigSet({
Expand Down
37 changes: 19 additions & 18 deletions src/legacy/ts-jest-transformer.ts
Expand Up @@ -86,25 +86,8 @@ export class TsJestTransformer implements SyncTransformer {
this._watchMode = ccs.watchMode
configSet = ccs.configSet
} else {
if (config.globals?.['ts-jest']) {
this._logger.warn(Deprecations.GlobalsTsJestConfigOption)
}
const jestGlobalsConfig = config.globals ?? {}
const tsJestGlobalsConfig = jestGlobalsConfig['ts-jest'] ?? {}
const migratedConfig = this.tsJestConfig
? {
...config,
globals: {
...jestGlobalsConfig,
'ts-jest': {
...tsJestGlobalsConfig,
...this.tsJestConfig,
},
},
}
: config
// try to look-it up by stringified version
const serializedJestCfg = stringify(migratedConfig)
const serializedJestCfg = stringify(config)
const serializedCcs = TsJestTransformer._cachedConfigSets.find(
(cs) => cs.jestConfig.serialized === serializedJestCfg,
)
Expand All @@ -122,6 +105,24 @@ export class TsJestTransformer implements SyncTransformer {
} else {
// create the new record in the index
this._logger.info('no matching config-set found, creating a new one')

if (config.globals?.['ts-jest']) {
this._logger.warn(Deprecations.GlobalsTsJestConfigOption)
}
const jestGlobalsConfig = config.globals ?? {}
const tsJestGlobalsConfig = jestGlobalsConfig['ts-jest'] ?? {}
const migratedConfig = this.tsJestConfig
? {
...config,
globals: {
...jestGlobalsConfig,
'ts-jest': {
...tsJestGlobalsConfig,
...this.tsJestConfig,
},
},
}
: config
configSet = this._createConfigSet(migratedConfig)
const jest = { ...migratedConfig }
// we need to remove some stuff from jest config
Expand Down

0 comments on commit 4e0623b

Please sign in to comment.