Skip to content

Commit 57c7af0

Browse files
authoredMar 30, 2020
fix(config): set default outDir for enabled allowJs without outDir (#1472)
1 parent ad58c9b commit 57c7af0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed
 

‎src/config/config-set.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,10 @@ describe('typescript', () => {
495495
})
496496
})
497497

498+
it('should include default outDir $$ts-jest$$ when allowJs is enabled and no outDir from config', () => {
499+
expect(get(void 0, { tsConfig: { allowJs: true } }).options.outDir).toBe('$$ts-jest$$')
500+
})
501+
498502
it('should be able to read extends', () => {
499503
const cs = createConfigSet({
500504
tsJestConfig: { tsConfig: 'tsconfig.build.json' },

‎src/config/config-set.ts

+4
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,10 @@ export class ConfigSet {
714714
finalOptions.allowSyntheticDefaultImports = true
715715
}
716716
}
717+
// Make sure when allowJs is enabled, outDir is set otherwise we run into error: Cannot write file ... because it would overwrite input
718+
if (finalOptions.allowJs && !finalOptions.outDir) {
719+
finalOptions.outDir = '$$ts-jest$$'
720+
}
717721

718722
// ensure undefined are removed and other values are overridden
719723
for (const key of Object.keys(forcedOptions)) {

0 commit comments

Comments
 (0)
Please sign in to comment.