Skip to content

Commit

Permalink
refactor(config): deprecate option tsConfig in favor of tsconfig (#…
Browse files Browse the repository at this point in the history
…1997)

The option `tsConfig` will be removed in v27
  • Loading branch information
ahnpnl committed Oct 2, 2020
1 parent 3add33b commit 8fec681
Show file tree
Hide file tree
Showing 20 changed files with 111 additions and 46 deletions.
2 changes: 1 addition & 1 deletion e2e/__cases__/deep/src/Tests/jest.config.js
Expand Up @@ -17,7 +17,7 @@ module.exports = Object.assign({}, cfg, {
testEnvironment: "node",
globals: {
"ts-jest": {
tsConfig: "./tsconfig.json",
tsconfig: "./tsconfig.json",
},
},
})
Expand Up @@ -14,7 +14,7 @@ module.exports = {
globals: {
'ts-jest': {
isolatedModules: true,
tsConfig: 'tsconfig-tests.json'
tsconfig: 'tsconfig-tests.json'
},
},
}
2 changes: 1 addition & 1 deletion e2e/__external-repos__/simple/with-dependency/package.json
Expand Up @@ -31,7 +31,7 @@
"globals": {
"ts-jest": {
"diagnostics": true,
"tsConfig": "<rootDir>/tsconfig.json"
"tsconfig": "<rootDir>/tsconfig.json"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion e2e/__templates__/default/jest.config.js
@@ -1,5 +1,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
globals: { 'ts-jest': { tsConfig: {} } },
globals: { 'ts-jest': { tsconfig: {} } },
}
@@ -1,5 +1,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
globals: { 'ts-jest': { tsConfig: {}, babelConfig: 'babel.config.js' } },
globals: { 'ts-jest': { tsconfig: {}, babelConfig: 'babel.config.js' } },
}
2 changes: 1 addition & 1 deletion e2e/__templates__/with-babel-7/jest.config.js
@@ -1,5 +1,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
globals: { 'ts-jest': { tsConfig: {}, babelConfig: true } },
globals: { 'ts-jest': { tsconfig: {}, babelConfig: true } },
}
2 changes: 1 addition & 1 deletion e2e/__templates__/with-unsupported-version/jest.config.js
@@ -1,5 +1,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
globals: { 'ts-jest': { tsConfig: {}, diagnostics: { ignoreCodes: [5023, 5024] } } },
globals: { 'ts-jest': { tsconfig: {}, diagnostics: { ignoreCodes: [5023, 5024] } } },
}
6 changes: 3 additions & 3 deletions e2e/__tests__/ast-transformers.test.ts
Expand Up @@ -22,7 +22,7 @@ describe('AST transformers', () => {

describe('path mapping', () => {
const tsJestConfig = {
tsConfig: {
tsconfig: {
baseUrl: '.',
paths: {
'@share/*': ['share/*']
Expand Down Expand Up @@ -53,8 +53,8 @@ describe('AST transformers', () => {
const testCase = configureTestCase('ast-transformers/path-mapping', {
tsJestConfig: {
...tsJestConfig,
tsConfig: {
...tsJestConfig.tsConfig,
tsconfig: {
...tsJestConfig.tsconfig,
rootDirs: ['./'],
},
},
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/logger.test.ts
Expand Up @@ -66,7 +66,7 @@ describe('ts-jest logging', () => {
env: { TS_JEST_LOG: 'ts-jest.log' },
noCache: true,
tsJestConfig: {
tsConfig: {
tsconfig: {
target: 'es2020' as any
}
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/module-kinds/helpers.ts
Expand Up @@ -9,7 +9,7 @@ import { configureTestCase } from '../../__helpers__/test-case'
// ESNext = 6

const testCaseForCompilerOpt = (config: any) => configureTestCase('module-kinds', {
tsJestConfig: { tsConfig: config, diagnostics: { warnOnly: true } },
tsJestConfig: { tsconfig: config, diagnostics: { warnOnly: true } },
noCache: true,
})

Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/source-map.test.ts
Expand Up @@ -48,7 +48,7 @@ describe('Source map', () => {
describe('with tsconfig mapRoot', () => {
runSourceMapTests({
...BASE_CONFIG,
tsConfig: {
tsconfig: {
mapRoot: './'
}
})
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/test-helpers.test.ts
Expand Up @@ -8,7 +8,7 @@ test('test-helpers', () => {
test('with esModuleInterop set to false', () => {
const test = configureTestCase('test-helpers', {
noCache: true,
tsJestConfig: { tsConfig: { esModuleInterop: false, allowSyntheticDefaultImports: false } },
tsJestConfig: { tsconfig: { esModuleInterop: false, allowSyntheticDefaultImports: false } },
})
expect(test.run(1)).toMatchSnapshot()
})
2 changes: 1 addition & 1 deletion jest-base.js
Expand Up @@ -2,7 +2,7 @@
module.exports = {
globals: {
'ts-jest': {
tsConfig: 'tsconfig.spec.json',
tsconfig: 'tsconfig.spec.json',
},
},
transform: {
Expand Down
14 changes: 7 additions & 7 deletions src/compiler/language-service.spec.ts
Expand Up @@ -10,7 +10,7 @@ import ProcessedSource from '../__helpers__/processed-source'
const logTarget = logTargetMock()

describe('Language service', () => {
const baseTsJestConfig = { tsConfig: require.resolve('../../tsconfig.spec.json') }
const baseTsJestConfig = { tsconfig: require.resolve('../../tsconfig.spec.json') }

beforeEach(() => {
logTarget.clear()
Expand All @@ -22,7 +22,7 @@ describe('Language service', () => {

it('should compile js file for allowJs true with outDir', () => {
const compiler = makeCompiler({
tsJestConfig: { tsConfig: { allowJs: true, outDir: '$$foo$$' } },
tsJestConfig: { tsconfig: { allowJs: true, outDir: '$$foo$$' } },
})

const compiled = compiler.compile(source, fileName)
Expand All @@ -32,7 +32,7 @@ describe('Language service', () => {

it('should compile js file for allowJs true without outDir', () => {
const compiler = makeCompiler({
tsJestConfig: { tsConfig: { allowJs: true } },
tsJestConfig: { tsconfig: { allowJs: true } },
})
const compiled = compiler.compile(source, fileName)

Expand All @@ -51,7 +51,7 @@ describe('Language service', () => {
it('should compile tsx file for jsx preserve', () => {
const compiler = makeCompiler({
tsJestConfig: {
tsConfig: {
tsconfig: {
jsx: 'preserve' as any,
},
},
Expand All @@ -65,7 +65,7 @@ describe('Language service', () => {
it('should compile tsx file for other jsx options', () => {
const compiler = makeCompiler({
tsJestConfig: {
tsConfig: {
tsconfig: {
jsx: 'react' as any,
},
},
Expand All @@ -81,7 +81,7 @@ describe('Language service', () => {
const fileName = 'test-source-map.ts'

it('should have correct source maps without mapRoot', () => {
const compiler = makeCompiler({ tsJestConfig: { tsConfig: require.resolve('../../tsconfig.spec.json') } })
const compiler = makeCompiler({ tsJestConfig: { tsconfig: require.resolve('../../tsconfig.spec.json') } })
const compiled = compiler.compile(source, fileName)

expect(new ProcessedSource(compiled, fileName).outputSourceMaps).toMatchObject({
Expand All @@ -94,7 +94,7 @@ describe('Language service', () => {
it('should have correct source maps with mapRoot', () => {
const compiler = makeCompiler({
tsJestConfig: {
tsConfig: {
tsconfig: {
mapRoot: './',
},
},
Expand Down
18 changes: 9 additions & 9 deletions src/compiler/transpiler.spec.ts
Expand Up @@ -10,7 +10,7 @@ describe('Transpiler', () => {
it('should compile js file for allowJs true', () => {
const fileName = 'foo.js'
const compiler = makeCompiler({
tsJestConfig: { ...baseTsJestConfig, tsConfig: { allowJs: true, outDir: TS_JEST_OUT_DIR } },
tsJestConfig: { ...baseTsJestConfig, tsconfig: { allowJs: true, outDir: TS_JEST_OUT_DIR } },
})
const source = 'export default 42'

Expand All @@ -31,7 +31,7 @@ describe('Transpiler', () => {
const compiler = makeCompiler({
tsJestConfig: {
...baseTsJestConfig,
tsConfig: {
tsconfig: {
jsx: 'preserve' as any,
},
},
Expand All @@ -45,7 +45,7 @@ describe('Transpiler', () => {
const compiler = makeCompiler({
tsJestConfig: {
...baseTsJestConfig,
tsConfig: {
tsconfig: {
jsx: 'react' as any,
},
},
Expand All @@ -61,7 +61,7 @@ describe('Transpiler', () => {
const fileName = 'test-source-map-transpiler.ts'

it('should have correct source maps without mapRoot', () => {
const compiler = makeCompiler({ tsJestConfig: { ...baseTsJestConfig, tsConfig: false } })
const compiler = makeCompiler({ tsJestConfig: { ...baseTsJestConfig, tsconfig: false } })
const compiled = compiler.compile(source, fileName)

expect(new ProcessedSource(compiled, fileName).outputSourceMaps).toMatchObject({
Expand All @@ -75,7 +75,7 @@ describe('Transpiler', () => {
const compiler = makeCompiler({
tsJestConfig: {
...baseTsJestConfig,
tsConfig: {
tsconfig: {
mapRoot: './',
},
},
Expand All @@ -92,7 +92,7 @@ describe('Transpiler', () => {

describe('diagnostics', () => {
it('should not report diagnostics related to typings', () => {
const compiler = makeCompiler({ tsJestConfig: { ...baseTsJestConfig, tsConfig: false } })
const compiler = makeCompiler({ tsJestConfig: { ...baseTsJestConfig, tsconfig: false } })

expect(() =>
compiler.compile(
Expand All @@ -107,7 +107,7 @@ const v: boolean = t
})

it('should report diagnostics related to codes with pathRegex config is undefined', () => {
const compiler = makeCompiler({ tsJestConfig: { ...baseTsJestConfig, tsConfig: false } })
const compiler = makeCompiler({ tsJestConfig: { ...baseTsJestConfig, tsconfig: false } })

expect(() =>
compiler.compile(
Expand All @@ -122,7 +122,7 @@ const t: string = f(5)

it('should report diagnostics related to codes with pathRegex config matches file name', () => {
const compiler = makeCompiler({
tsJestConfig: { ...baseTsJestConfig, tsConfig: false, diagnostics: { pathRegex: 'foo.ts' } },
tsJestConfig: { ...baseTsJestConfig, tsconfig: false, diagnostics: { pathRegex: 'foo.ts' } },
})

expect(() =>
Expand All @@ -138,7 +138,7 @@ const t: string = f(5)

it('should not report diagnostics related to codes with pathRegex config does not match file name', () => {
const compiler = makeCompiler({
tsJestConfig: { ...baseTsJestConfig, tsConfig: false, diagnostics: { pathRegex: 'bar.ts' } },
tsJestConfig: { ...baseTsJestConfig, tsconfig: false, diagnostics: { pathRegex: 'bar.ts' } },
})

expect(() =>
Expand Down
5 changes: 5 additions & 0 deletions src/config/__snapshots__/config-set.spec.ts.snap
Expand Up @@ -366,3 +366,8 @@ Array [
},
]
`;
exports[`tsJest tsconfig should show warning message with tsConfig option 1`] = `
"[level:40] The option \`tsConfig\` is deprecated and will be removed in ts-jest 27, use \`tsconfig\` instead
"
`;

0 comments on commit 8fec681

Please sign in to comment.