From 57c7af0bd6e12cb683894c39303affa2111f8ea0 Mon Sep 17 00:00:00 2001 From: Ahn Date: Mon, 30 Mar 2020 19:30:15 +0200 Subject: [PATCH] fix(config): set default outDir for enabled allowJs without outDir (#1472) --- src/config/config-set.spec.ts | 4 ++++ src/config/config-set.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/config/config-set.spec.ts b/src/config/config-set.spec.ts index fa7593768a..bee8825f0c 100644 --- a/src/config/config-set.spec.ts +++ b/src/config/config-set.spec.ts @@ -495,6 +495,10 @@ describe('typescript', () => { }) }) + it('should include default outDir $$ts-jest$$ when allowJs is enabled and no outDir from config', () => { + expect(get(void 0, { tsConfig: { allowJs: true } }).options.outDir).toBe('$$ts-jest$$') + }) + it('should be able to read extends', () => { const cs = createConfigSet({ tsJestConfig: { tsConfig: 'tsconfig.build.json' }, diff --git a/src/config/config-set.ts b/src/config/config-set.ts index 47214ab300..c75f7fbaa8 100644 --- a/src/config/config-set.ts +++ b/src/config/config-set.ts @@ -714,6 +714,10 @@ export class ConfigSet { finalOptions.allowSyntheticDefaultImports = true } } + // Make sure when allowJs is enabled, outDir is set otherwise we run into error: Cannot write file ... because it would overwrite input + if (finalOptions.allowJs && !finalOptions.outDir) { + finalOptions.outDir = '$$ts-jest$$' + } // ensure undefined are removed and other values are overridden for (const key of Object.keys(forcedOptions)) {