From 9c9fd6097aea36a6e8b06b0e8841df22896f9121 Mon Sep 17 00:00:00 2001 From: Ahn <27772165+ahnpnl@users.noreply.github.com> Date: Tue, 27 Sep 2022 14:07:45 +0200 Subject: [PATCH] fix: merge config from `globals` with transformer config correctly (#3842) Fixes #3841 --- src/legacy/ts-jest-transformer.spec.ts | 2 +- src/legacy/ts-jest-transformer.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/legacy/ts-jest-transformer.spec.ts b/src/legacy/ts-jest-transformer.spec.ts index f24a5df772..849e2d3041 100644 --- a/src/legacy/ts-jest-transformer.spec.ts +++ b/src/legacy/ts-jest-transformer.spec.ts @@ -304,7 +304,7 @@ describe('TsJestTransformer', () => { let tr!: TsJestTransformer beforeEach(() => { - tr = new TsJestTransformer() + tr = new TsJestTransformer({}) jest.spyOn(TsJestCompiler.prototype, 'getResolvedModules').mockReturnValueOnce([]) }) diff --git a/src/legacy/ts-jest-transformer.ts b/src/legacy/ts-jest-transformer.ts index 7f118434f7..b4dbdc2a20 100644 --- a/src/legacy/ts-jest-transformer.ts +++ b/src/legacy/ts-jest-transformer.ts @@ -109,12 +109,17 @@ export class TsJestTransformer implements SyncTransformer { 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: { - ...(config.globals ?? Object.create(null)), - 'ts-jest': this.tsJestConfig, + ...jestGlobalsConfig, + 'ts-jest': { + ...tsJestGlobalsConfig, + ...this.tsJestConfig, + }, }, } : config