From e79be47d2b81a677d0dd39d84328a38ca0f0ffc6 Mon Sep 17 00:00:00 2001 From: Ahn <27772165+ahnpnl@users.noreply.github.com> Date: Sun, 11 Sep 2022 18:49:45 +0200 Subject: [PATCH] fix(legacy): include existing globals config in cached config (#3803) When creating `ConfigSet` with migrated Jest config (to migrate from `globals` to transformer config), it is a must to also copy other globals config. --- src/legacy/ts-jest-transformer.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/legacy/ts-jest-transformer.ts b/src/legacy/ts-jest-transformer.ts index 235126db59..7f118434f7 100644 --- a/src/legacy/ts-jest-transformer.ts +++ b/src/legacy/ts-jest-transformer.ts @@ -109,17 +109,17 @@ export class TsJestTransformer implements SyncTransformer { if (config.globals?.['ts-jest']) { this._logger.warn(Deprecations.GlobalsTsJestConfigOption) } - configSet = this._createConfigSet( - this.tsJestConfig - ? { - ...config, - globals: { - 'ts-jest': this.tsJestConfig, - }, - } - : config, - ) - const jest = { ...config } + const migratedConfig = this.tsJestConfig + ? { + ...config, + globals: { + ...(config.globals ?? Object.create(null)), + 'ts-jest': this.tsJestConfig, + }, + } + : config + configSet = this._createConfigSet(migratedConfig) + const jest = { ...migratedConfig } // we need to remove some stuff from jest config // this which does not depend on config jest.cacheDirectory = undefined as any // eslint-disable-line @typescript-eslint/no-explicit-any