Skip to content

Commit 3cc9b80

Browse files
authoredNov 10, 2020
refactor(config): remove support for tsConfig option (#2127)
BREAKING CHANGE: One currently uses `tsConfig` should change to `tsconfig` in your `jest.config.js` or `package.json`
1 parent 152374c commit 3cc9b80

File tree

13 files changed

+212
-316
lines changed

13 files changed

+212
-316
lines changed
 

‎docs/user/config/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ All options have default values which should fit most of the projects. Click on
207207
| Option | Description | Type | Default |
208208
|---|---|---|---|
209209
| [**`compiler`**][compiler] | [TypeScript module to use as compiler.][compiler] | `string` | `"typescript"` |
210-
| [**`tsConfig` or `tsconfig`**][tsConfig] | [TypeScript compiler related configuration.][tsConfig] | `string`\|`object`\|`boolean` | _auto_ |
210+
| [**`tsconfig`**][tsconfig] | [TypeScript compiler related configuration.][tsconfig] | `string`\|`object`\|`boolean` | _auto_ |
211211
| [**`isolatedModules`**][isolatedModules] | [Disable type-checking][isolatedModules] | `boolean` | _disabled_ |
212212
| [**`astTransformers`**][astTransformers] | [Custom TypeScript AST transformers][astTransformers] | `object` | _auto_ |
213213
| [**`diagnostics`**][diagnostics] | [Diagnostics related configuration.][diagnostics] | `boolean`\|`object` | _enabled_ |
@@ -260,7 +260,7 @@ npx ts-jest config:migrate package.json
260260
</div></div>
261261

262262
[compiler]: compiler
263-
[tsConfig]: tsConfig
263+
[tsconfig]: tsconfig
264264
[isolatedModules]: isolatedModules
265265
[astTransformers]: astTransformers
266266
[compilerHost]: compilerHost

‎docs/user/config/tsConfig.md ‎docs/user/config/tsconfig.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = {
3737
"jest": {
3838
"globals": {
3939
"ts-jest": {
40-
"tsConfig": "tsconfig.test.json"
40+
"tsconfig": "tsconfig.test.json"
4141
}
4242
}
4343
}
@@ -76,7 +76,7 @@ module.exports = {
7676
"jest": {
7777
"globals": {
7878
"ts-jest": {
79-
"tsConfig": {
79+
"tsconfig": {
8080
"importHelpers": true
8181
}
8282
}
@@ -114,7 +114,7 @@ module.exports = {
114114
"jest": {
115115
"globals": {
116116
"ts-jest": {
117-
"tsConfig": false
117+
"tsconfig": false
118118
}
119119
}
120120
}

‎e2e/__tests__/__snapshots__/logger.test.ts.snap

-57
Original file line numberDiff line numberDiff line change
@@ -244,63 +244,6 @@ exports[`ts-jest logging deprecation warning with packageJson config should pass
244244
================================================================================
245245
`;
246246
247-
exports[`ts-jest logging deprecation warning with tsConfig config should pass using template "default" 1`] = `
248-
√ jest
249-
↳ exit code: 0
250-
===[ STDOUT ]===================================================================
251-
252-
===[ STDERR ]===================================================================
253-
ts-jest[config] (WARN) The option \`tsConfig\` is deprecated and will be removed in ts-jest 27, use \`tsconfig\` instead
254-
PASS ./Hello.spec.ts
255-
Hello Class
256-
√ should create a new Hello
257-
258-
Test Suites: 1 passed, 1 total
259-
Tests: 1 passed, 1 total
260-
Snapshots: 0 total
261-
Time: XXs
262-
Ran all test suites.
263-
================================================================================
264-
`;
265-
266-
exports[`ts-jest logging deprecation warning with tsConfig config should pass using template "with-babel-7" 1`] = `
267-
√ jest
268-
↳ exit code: 0
269-
===[ STDOUT ]===================================================================
270-
271-
===[ STDERR ]===================================================================
272-
ts-jest[config] (WARN) The option \`tsConfig\` is deprecated and will be removed in ts-jest 27, use \`tsconfig\` instead
273-
PASS ./Hello.spec.ts
274-
Hello Class
275-
√ should create a new Hello
276-
277-
Test Suites: 1 passed, 1 total
278-
Tests: 1 passed, 1 total
279-
Snapshots: 0 total
280-
Time: XXs
281-
Ran all test suites.
282-
================================================================================
283-
`;
284-
285-
exports[`ts-jest logging deprecation warning with tsConfig config should pass using template "with-babel-7-string-config" 1`] = `
286-
√ jest
287-
↳ exit code: 0
288-
===[ STDOUT ]===================================================================
289-
290-
===[ STDERR ]===================================================================
291-
ts-jest[config] (WARN) The option \`tsConfig\` is deprecated and will be removed in ts-jest 27, use \`tsconfig\` instead
292-
PASS ./Hello.spec.ts
293-
Hello Class
294-
√ should create a new Hello
295-
296-
Test Suites: 1 passed, 1 total
297-
Tests: 1 passed, 1 total
298-
Snapshots: 0 total
299-
Time: XXs
300-
Ran all test suites.
301-
================================================================================
302-
`;
303-
304247
exports[`ts-jest logging with unsupported version test with TS_JEST_DISABLE_VER_CHECKER is not set in process.env should pass using template "with-unsupported-version" 1`] = `
305248
√ jest
306249
↳ exit code: 0

‎e2e/__tests__/logger.test.ts

-16
Original file line numberDiff line numberDiff line change
@@ -123,21 +123,5 @@ describe('ts-jest logging', () => {
123123
})
124124
})
125125
})
126-
127-
describe('with tsConfig config', () => {
128-
const testCase = configureTestCase('simple', {
129-
tsJestConfig: {
130-
tsConfig: true,
131-
}
132-
})
133-
134-
testCase.runWithTemplates(allPackageSetsWithPreset, 0, (runTest, { testLabel }) => {
135-
it(testLabel, () => {
136-
const result = runTest()
137-
expect(result.status).toBe(0)
138-
expect(result).toMatchSnapshot()
139-
})
140-
})
141-
})
142126
})
143127
})

‎src/__helpers__/fakers.ts

+1-14
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { resolve } from 'path'
44

55
import { createCompilerInstance } from '../compiler/instance'
66
import { ConfigSet } from '../config/config-set'
7-
import type { BabelConfig, TsCompiler, TsJestConfig, TsJestGlobalOptions } from '../types'
7+
import type { BabelConfig, TsCompiler, TsJestGlobalOptions } from '../types'
88
import type { ImportReasons } from '../utils/messages'
99

1010
export function filePath(relPath: string): string {
@@ -13,19 +13,6 @@ export function filePath(relPath: string): string {
1313

1414
export const rootDir = filePath('')
1515

16-
export function tsJestConfig(options?: Partial<TsJestConfig>): TsJestConfig {
17-
return {
18-
isolatedModules: false,
19-
compiler: 'typescript',
20-
transformers: options?.transformers ?? Object.create(null),
21-
babelConfig: undefined,
22-
tsConfig: undefined,
23-
stringifyContentPathRegex: undefined,
24-
diagnostics: { ignoreCodes: [], pretty: false, throws: true },
25-
...options,
26-
}
27-
}
28-
2916
function getJestConfig<T extends Config.ProjectConfig>(
3017
options?: Partial<Config.InitialOptions | Config.ProjectConfig>,
3118
tsJestOptions?: TsJestGlobalOptions,

‎src/cli/cli.spec.ts

+192-192
Large diffs are not rendered by default.

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ describe('parsedTsConfig', () => {
6060
expect(get().fileNames).toContain(normalizeSlashes(__filename))
6161
})
6262

63-
it.each(['tsConfig', 'tsconfig'])('should include compiler config from `%s` option key', (key: string) => {
64-
expect(get({ [key]: { baseUrl: 'src/config' } }).options.baseUrl).toBe(normalizeSlashes(__dirname))
63+
it('should include compiler config from `%s` option key', () => {
64+
expect(get({ tsconfig: { baseUrl: 'src/config' } }).options.baseUrl).toBe(normalizeSlashes(__dirname))
6565
})
6666

6767
it('should include compiler config from base config', () => {

‎src/config/config-set.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,7 @@ export class ConfigSet {
274274
this.logger.debug({ diagnostics: this._diagnostics }, 'normalized diagnostics config via ts-jest option')
275275

276276
// tsconfig
277-
if (options.tsConfig) {
278-
this.logger.warn(Deprecations.TsConfig)
279-
}
280-
const tsconfigOpt = options.tsConfig ?? options.tsconfig
277+
const tsconfigOpt = options.tsconfig
281278
const configFilePath = typeof tsconfigOpt === 'string' ? this.resolvePath(tsconfigOpt) : undefined
282279
this.parsedTsConfig = this._resolveTsConfig(
283280
typeof tsconfigOpt === 'object' ? tsconfigOpt : undefined,

‎src/transformers/path-mapping.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ describe('path-mapping', () => {
5050
},
5151
])(
5252
'should replace alias path with relative path which is resolved from paths tsconfig with js/ts extension',
53-
(tsConfig) => {
53+
(tsconfig) => {
5454
const configSet = createConfigSet({
5555
tsJestConfig: {
56-
tsConfig,
56+
tsconfig,
5757
},
5858
logger,
5959
})

‎src/types.ts

+1-14
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,6 @@ export interface TsJestGlobalOptions {
4444
* - `{...}`: an object with inline compiler options
4545
*
4646
* @default undefined uses the default tsconfig file
47-
* @alias tsconfig
48-
*/
49-
tsConfig?: boolean | string | _ts.CompilerOptions
50-
51-
/**
52-
* Compiler options. It can be:
53-
* - `true` (or `undefined`, it's the default): use default tsconfig file
54-
* - `false`: do NOT use default config file
55-
* - `path/to/tsconfig.json`: path to a specific tsconfig file (<rootDir> can be used)
56-
* - `{...}`: an object with inline compiler options
57-
*
58-
* @default undefined uses the default tsconfig file
59-
* @alias tsConfig
6047
*/
6148
tsconfig?: boolean | string | _ts.CompilerOptions
6249

@@ -176,7 +163,7 @@ type TsJestConfig$babelConfig = TsJestConfig$babelConfig$file | TsJestConfig$bab
176163
* @internal
177164
*/
178165
export interface TsJestConfig {
179-
tsConfig: TsJestConfig$tsConfig
166+
tsconfig: TsJestConfig$tsConfig
180167
isolatedModules: boolean
181168
compiler: string
182169
diagnostics: TsJestDiagnosticsCfg

‎src/utils/__snapshots__/backports.spec.ts.snap

+4-4
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ exports[`backportJestConfig with "globals.__TS_CONFIG__" set to { foo: 'bar' } s
6666
Object {
6767
"globals": Object {
6868
"ts-jest": Object {
69-
"tsConfig": Object {
69+
"tsconfig": Object {
7070
"foo": "bar",
7171
},
7272
},
@@ -76,7 +76,7 @@ Object {
7676
7777
exports[`backportJestConfig with "globals.__TS_CONFIG__" set to { foo: 'bar' } should warn the user 1`] = `
7878
Array [
79-
"[level:40] \\"[jest-config].globals.__TS_CONFIG__\\" is deprecated, use \\"[jest-config].globals.ts-jest.tsConfig\\" instead.
79+
"[level:40] \\"[jest-config].globals.__TS_CONFIG__\\" is deprecated, use \\"[jest-config].globals.ts-jest.tsconfig\\" instead.
8080
",
8181
"[level:40] Your Jest configuration is outdated. Use the CLI to help migrating it: ts-jest config:migrate <config-file>.
8282
",
@@ -245,15 +245,15 @@ exports[`backportJestConfig with "globals.ts-jest.tsConfigFile" set to 'tsconfig
245245
Object {
246246
"globals": Object {
247247
"ts-jest": Object {
248-
"tsConfig": "tsconfig.build.json",
248+
"tsconfig": "tsconfig.build.json",
249249
},
250250
},
251251
}
252252
`;
253253
254254
exports[`backportJestConfig with "globals.ts-jest.tsConfigFile" set to 'tsconfig.build.json' should warn the user 1`] = `
255255
Array [
256-
"[level:40] \\"[jest-config].globals.ts-jest.tsConfigFile\\" is deprecated, use \\"[jest-config].globals.ts-jest.tsConfig\\" instead.
256+
"[level:40] \\"[jest-config].globals.ts-jest.tsConfigFile\\" is deprecated, use \\"[jest-config].globals.ts-jest.tsconfig\\" instead.
257257
",
258258
"[level:40] Your Jest configuration is outdated. Use the CLI to help migrating it: ts-jest config:migrate <config-file>.
259259
",

‎src/utils/backports.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ export const backportJestConfig = <T extends Config.InitialOptions | Config.Proj
3131
}
3232

3333
if ('__TS_CONFIG__' in globals) {
34-
warnConfig('globals.__TS_CONFIG__', 'globals.ts-jest.tsConfig')
34+
warnConfig('globals.__TS_CONFIG__', 'globals.ts-jest.tsconfig')
3535
if (typeof globals.__TS_CONFIG__ === 'object') {
36-
mergeTsJest.tsConfig = globals.__TS_CONFIG__
36+
mergeTsJest.tsconfig = globals.__TS_CONFIG__
3737
}
3838
delete globals.__TS_CONFIG__
3939
}
@@ -53,9 +53,9 @@ export const backportJestConfig = <T extends Config.InitialOptions | Config.Proj
5353
}
5454

5555
if ('tsConfigFile' in tsJest) {
56-
warnConfig('globals.ts-jest.tsConfigFile', 'globals.ts-jest.tsConfig')
56+
warnConfig('globals.ts-jest.tsConfigFile', 'globals.ts-jest.tsconfig')
5757
if (tsJest.tsConfigFile) {
58-
mergeTsJest.tsConfig = tsJest.tsConfigFile
58+
mergeTsJest.tsconfig = tsJest.tsConfigFile
5959
}
6060
delete tsJest.tsConfigFile
6161
}

‎src/utils/messages.ts

-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export const enum Errors {
1616
GotUnknownFileTypeWithoutBabel = 'Got a unknown file type to compile (file: {{path}}). To fix this, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match this kind of files anymore.',
1717
GotUnknownFileTypeWithBabel = 'Got a unknown file type to compile (file: {{path}}). To fix this, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match this kind of files anymore. If you still want Babel to process it, add another entry to the `transform` option with value `babel-jest` which key matches this type of files.',
1818
ConfigNoModuleInterop = 'If you have issues related to imports, you should consider setting `esModuleInterop` to `true` in your TypeScript configuration file (usually `tsconfig.json`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information.',
19-
UnableToFindProjectRoot = 'Unable to find the root of the project where ts-jest has been installed.',
2019
MismatchNodeTargetMapping = 'There is a mismatch between your NodeJs version {{nodeJsVer}} and your TypeScript target {{compilationTarget}}. This might lead to some unexpected errors when running tests with `ts-jest`. To fix this, you can check https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping',
2120
}
2221

@@ -38,7 +37,6 @@ export const enum Deprecations {
3837
ConfigOptionUseBabelRcNote = 'See `babel-jest` related issue: https://github.com/facebook/jest/issues/3845',
3938
HelperMovedToUtils = "The `{{helper}}` helper has been moved to `ts-jest/utils`. Use `import { {{helper}} } from 'ts-jest/utils'` instead.",
4039
AstTransformerArrayConfig = 'The configuration for astTransformers as string[] is deprecated and will be removed in ts-jest 27. Please define your custom AST transformers in a form of an object. More information you can check online documentation https://kulshekhar.github.io/ts-jest/user/config/astTransformers',
41-
TsConfig = 'The option `tsConfig` is deprecated and will be removed in ts-jest 27, use `tsconfig` instead',
4240
PackageJson = 'The option `packageJson` is deprecated and will be removed in ts-jest 27. This option is not used by internal `ts-jest`',
4341
}
4442

0 commit comments

Comments
 (0)
Please sign in to comment.