Skip to content

Commit

Permalink
Always remove outDir while computing TypeScript Config for transpiling (
Browse files Browse the repository at this point in the history
#311)

Always remove outDir while computing TypeScript Config for transpiling
  • Loading branch information
trivikr authored and kulshekhar committed Sep 1, 2017
1 parent 64bbc6e commit 27a205b
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 14 deletions.
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ Orta Therox <[email protected]>
Patrick Housley <[email protected]>
Rikki Tooley <[email protected]>
Tom Crockett <[email protected]>
Trivikram Kamat <[email protected]>
Umidbek Karimov <[email protected]>

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ts-jest",
"version": "20.0.13",
"version": "20.0.14",
"main": "index.js",
"types": "./dist/index.d.ts",
"description": "A preprocessor with sourcemap support to help use Typescript with Jest",
Expand Down
10 changes: 5 additions & 5 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ export function getTSConfig(globals, collectCoverage: boolean = false) {
config.inlineSourceMap = true;
config.inlineSources = true;

if (collectCoverage) {
// the coverage report is broken if `.outDir` is set
// see https://github.com/kulshekhar/ts-jest/issues/201
delete config.outDir;
}
// the coverage report is broken if `.outDir` is set
// see https://github.com/kulshekhar/ts-jest/issues/201
// `.outDir` is removed even for test files as it affects with breakpoints
// see https://github.com/kulshekhar/ts-jest/issues/309
delete config.outDir;

// Note: If we had to read the inline configuration, it's required to set the fields
// to their string properties, and convert the result accordingly afterwards.
Expand Down
3 changes: 2 additions & 1 deletion tests/__tests__/tsconfig-default.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ describe('get default ts config', () => {
it('should correctly read tsconfig.json', () => {
const result = getTSConfig(null);

expect(result).toMatchObject({
expect(result).toEqual({
inlineSourceMap: true,
inlineSources: true,
target: ts.ScriptTarget.ES2015,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
Expand Down
21 changes: 20 additions & 1 deletion tests/__tests__/tsconfig-inline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,27 @@ describe('get inline ts config', () => {
},
});

expect(result).toMatchObject({
expect(result).toEqual({
inlineSourceMap: true,
inlineSources: true,
module: ts.ModuleKind.CommonJS,
jsx: ts.JsxEmit.React,
});
});

it('should not read sourceMap/outDir from tsconfig options', () => {
const result = getTSConfig({
__TS_CONFIG__: {
module: 'commonjs',
jsx: 'react',
outDir: 'build',
sourceMap: true,
},
});

expect(result).toEqual({
inlineSourceMap: true,
inlineSources: true,
module: ts.ModuleKind.CommonJS,
jsx: ts.JsxEmit.React,
});
Expand Down
16 changes: 11 additions & 5 deletions tests/__tests__/tsconfig-string.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ describe('get ts config from string', () => {
__TS_CONFIG__: 'my-tsconfig.json',
});

expect(result).toMatchObject({
expect(result).toEqual({
inlineSourceMap: true,
inlineSources: true,
target: ts.ScriptTarget.ES2015,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
Expand Down Expand Up @@ -56,8 +57,9 @@ describe('get ts config from string', () => {
__TS_CONFIG__: 'extends-tsconfig.json',
});

expect(result).toMatchObject({
expect(result).toEqual({
inlineSourceMap: true,
inlineSources: true,
target: ts.ScriptTarget.ES2015,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
Expand All @@ -71,8 +73,9 @@ describe('get ts config from string', () => {
__TS_CONFIG__: 'extends-with-overrides-tsconfig.json',
});

expect(result).toMatchObject({
expect(result).toEqual({
inlineSourceMap: true,
inlineSources: true,
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
Expand All @@ -93,6 +96,7 @@ describe('get ts config from string', () => {

expect(result).toMatchObject({
inlineSourceMap: true,
inlineSources: true,
target: ts.ScriptTarget.ES2015,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
Expand Down Expand Up @@ -137,8 +141,9 @@ describe('get ts config from string', () => {
},
});

expect(result).toMatchObject({
expect(result).toEqual({
inlineSourceMap: true,
inlineSources: true,
target: ts.ScriptTarget.ES2015,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
Expand All @@ -154,8 +159,9 @@ describe('get ts config from string', () => {
},
});

expect(result).toMatchObject({
expect(result).toEqual({
inlineSourceMap: true,
inlineSources: true,
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
Expand Down

0 comments on commit 27a205b

Please sign in to comment.