Skip to content

Commit

Permalink
Revert "fix(transformer): don't use cache when tsJestConfig is diff…
Browse files Browse the repository at this point in the history
…erent (#3966)"

This reverts commit a445638.
  • Loading branch information
ahnpnl committed Jan 12, 2023
1 parent d30d389 commit 185eb18
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 185eb18

Please sign in to comment.