Skip to content

Commit 31e5843

Browse files
authored
feat: migrate globals config to transformer config (#3780)
DEPRECATION Define `ts-jest` config under `globals` is now deprecated. Please define the config via transformer config instead.
1 parent c8be99d commit 31e5843

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+405
-328
lines changed
Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`partial successfully runs the tests inside const-enum with 'isolatedModules: true' 1`] = `
4-
"FAIL __tests__/import-from-d-ts-no-js.spec.ts
5-
● Test suite failed to run
6-
7-
Cannot find module '../hoo-constant' from '__tests__/import-from-d-ts-no-js.spec.ts'
8-
9-
However, Jest was able to find:
10-
'../hoo-constant.d.ts'
11-
12-
You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'mjs', 'cjs', 'jsx', 'ts', 'tsx', 'json', 'node'].
13-
14-
See https://jestjs.io/docs/configuration#modulefileextensions-arraystring
15-
16-
> 1 | import { HooConstEnum } from '../hoo-constant'
17-
| ^
18-
2 |
19-
3 | const getTwo = (): string => HooConstEnum.two
20-
4 |
21-
22-
at Resolver._throwModNotFoundError (../../node_modules/jest-resolve/build/resolver.js:487:11)
23-
at Object.<anonymous> (__tests__/import-from-d-ts-no-js.spec.ts:1:1)
24-
25-
PASS __tests__/import-from-d-ts-has-js.spec.ts
4+
"PASS __tests__/import-from-d-ts-has-js.spec.ts
5+
PASS __tests__/import-from-d-ts-no-js.spec.ts
266
PASS __tests__/import-from-ts.spec.ts"
277
`;
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/** @type {import('../../../dist').InitialOptionsTsJest} */
22
module.exports = {
33
automock: true,
4-
globals: {
5-
'ts-jest': {
6-
isolatedModules: true,
7-
tsconfig: {
8-
allowJs: true,
9-
},
10-
},
11-
},
124
moduleNameMapper: {
135
react$: '<rootDir>/node_modules/react',
146
},
157
transform: {
16-
'^.+.[tj]sx?$': '<rootDir>/../../../legacy.js',
8+
'^.+.[tj]sx?$': [
9+
'<rootDir>/../../../legacy.js',
10+
{
11+
isolatedModules: true,
12+
tsconfig: {
13+
allowJs: true,
14+
},
15+
},
16+
],
1717
},
1818
}

e2e/ast-transformers/hoist-jest/package.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,15 @@
44
},
55
"jest": {
66
"automock": true,
7-
"globals": {
8-
"ts-jest": {
9-
"tsconfig": {
10-
"allowJs": true
11-
}
12-
}
13-
},
147
"moduleNameMapper": {
158
"react$": "<rootDir>/node_modules/react"
169
},
1710
"transform": {
18-
"^.+\\.[tj]sx?$": "<rootDir>/../../../legacy.js"
11+
"^.+\\.[tj]sx?$": ["<rootDir>/../../../legacy.js", {
12+
"tsconfig": {
13+
"allowJs": true
14+
}
15+
}]
1916
}
2017
}
2118
}

e2e/ast-transformers/transformer-in-ts/package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
"esbuild": "~0.15.5"
44
},
55
"jest": {
6-
"globals": {
7-
"ts-jest": {
6+
"transform": {
7+
"^.+\\.[tj]sx?$": ["<rootDir>/../../../legacy.js", {
88
"astTransformers": {
99
"before": ["<rootDir>/../../../src/transformers/hoist-jest.ts"]
1010
}
11-
}
12-
},
13-
"transform": {
14-
"^.+\\.[tj]sx?$": "<rootDir>/../../../legacy.js"
11+
}]
1512
}
1613
}
1714
}
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/** @type {import('../../../dist').InitialOptionsTsJest} */
22
module.exports = {
3-
globals: {
4-
'ts-jest': {
5-
isolatedModules: true,
6-
astTransformers: {
7-
before: [
8-
{
9-
path: '<rootDir>/node_modules/@formatjs/ts-transformer/ts-jest-integration',
10-
options: {
11-
removeDefaultMessage: true,
3+
transform: {
4+
'^.+.[tj]sx?$': [
5+
'<rootDir>/../../../legacy.js',
6+
{
7+
isolatedModules: true,
8+
astTransformers: {
9+
before: [
10+
{
11+
path: '<rootDir>/node_modules/@formatjs/ts-transformer/ts-jest-integration',
12+
options: {
13+
removeDefaultMessage: true,
14+
},
1215
},
13-
},
14-
],
16+
],
17+
},
1518
},
16-
},
17-
},
18-
transform: {
19-
'^.+.[tj]sx?$': '<rootDir>/../../../legacy.js',
19+
],
2020
},
2121
}

e2e/ast-transformers/transformer-options/package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"react-intl": "^6.1.0"
66
},
77
"jest": {
8-
"globals": {
9-
"ts-jest": {
8+
"transform": {
9+
"^.+\\.[tj]sx?$": ["<rootDir>/../../../legacy.js", {
1010
"astTransformers": {
1111
"before": [
1212
{
@@ -17,10 +17,7 @@
1717
}
1818
]
1919
}
20-
}
21-
},
22-
"transform": {
23-
"^.+\\.[tj]sx?$": "<rootDir>/../../../legacy.js"
20+
}]
2421
}
2522
}
2623
}

e2e/config-typing/jest.config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import type { InitialOptionsTsJest } from 'ts-jest'
22

33
const jestCfg: InitialOptionsTsJest = {
4-
globals: {
5-
'ts-jest': {
6-
isolatedModules: true,
7-
},
8-
},
94
transform: {
10-
'^.+.tsx?$': 'ts-jest',
5+
'^.+.tsx?$': [
6+
'ts-jest',
7+
{
8+
isolatedModules: true,
9+
},
10+
],
1111
},
1212
}
1313

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/** @type {import('../../dist').InitialOptionsTsJest} */
22
module.exports = {
3-
globals: {
4-
'ts-jest': {
5-
isolatedModules: true,
6-
},
7-
},
83
transform: {
9-
'^.+.tsx?$': '<rootDir>/../../legacy.js',
4+
'^.+.tsx?$': [
5+
'<rootDir>/../../legacy.js',
6+
{
7+
'ts-jest': {
8+
isolatedModules: true,
9+
},
10+
},
11+
],
1012
},
1113
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/** @type {import('../../dist').InitialOptionsTsJest} */
22
module.exports = {
33
collectCoverageFrom: ['**/*.js', '**/*.ts', '!**/node_modules/**', '!**/coverage/**'],
4-
globals: {
5-
'ts-jest': {
6-
isolatedModules: true,
7-
},
8-
},
94
transform: {
10-
'^.+.tsx?$': '<rootDir>/../../legacy.js',
5+
'^.+.tsx?$': [
6+
'<rootDir>/../../legacy.js',
7+
{
8+
isolatedModules: true,
9+
},
10+
],
1111
},
1212
}

e2e/custom-compiler/ttypescript/package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@
44
"ttypescript": "^1.5.13"
55
},
66
"jest": {
7-
"globals": {
8-
"ts-jest": {
9-
"compiler": "ttypescript"
10-
}
11-
},
127
"transform": {
13-
"^.+.tsx?$": "<rootDir>/../../../legacy.js"
8+
"^.+.tsx?$": ["<rootDir>/../../../legacy.js", {
9+
"compiler": "ttypescript"
10+
}]
1411
}
1512
}
1613
}

0 commit comments

Comments
 (0)