Skip to content

Commit

Permalink
fix: merge config from globals with transformer config correctly (#…
Browse files Browse the repository at this point in the history
…3842)

Fixes #3841
  • Loading branch information
ahnpnl authored Sep 27, 2022
1 parent c76195b commit 9c9fd60
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/legacy/ts-jest-transformer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ describe('TsJestTransformer', () => {
let tr!: TsJestTransformer

beforeEach(() => {
tr = new TsJestTransformer()
tr = new TsJestTransformer({})
jest.spyOn(TsJestCompiler.prototype, 'getResolvedModules').mockReturnValueOnce([])
})

Expand Down
9 changes: 7 additions & 2 deletions src/legacy/ts-jest-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9c9fd60

Please sign in to comment.