Skip to content

Commit 22fb027

Browse files
committed
feat(cli): allow migrating cjs presets to transform config
1 parent 72074d2 commit 22fb027

File tree

3 files changed

+284
-253
lines changed

3 files changed

+284
-253
lines changed

src/cli/__snapshots__/cli.spec.ts.snap

+76-20
Original file line numberDiff line numberDiff line change
@@ -110,44 +110,80 @@ exports[`config init should update package.json for config type js-with-ts-full-
110110
}"
111111
`;
112112

113-
exports[`config migrate should migrate globals ts-jest config to transformer config 1`] = `
114-
""jest": {
115-
"transform": {
116-
"^.+\\\\.tsx?$": [
117-
"ts-jest",
118-
{
119-
"tsconfig": "./tsconfig.json"
120-
}
121-
]
113+
exports[`config migrate should generate transform config with existing transform options for js-with-babel 1`] = `
114+
"module.exports = {
115+
transform: {
116+
'^.+.jsx?$': 'babel-jest',
117+
'^.+.tsx?$': [
118+
'ts-jest',
119+
{},
120+
],
121+
},
122+
}
123+
"
124+
`;
125+
126+
exports[`config migrate should generate transform config with existing transform options for js-with-ts 1`] = `
127+
"module.exports = {
128+
transform: {
129+
'^.+.[tj]sx?$': [
130+
'ts-jest',
131+
{},
132+
],
133+
'^.+.tsx?$': [
134+
'ts-jest',
135+
{},
136+
],
122137
},
123-
"preset": "ts-jest/presets/js-with-babel"
124138
}
125139
"
126140
`;
127141

128142
exports[`config migrate should migrate preset if valid preset value is used 1`] = `
143+
""jest": {
144+
"transform": {
145+
"^.+.tsx?$": [
146+
"ts-jest",
147+
{}
148+
]
149+
}
150+
}
129151
"
130-
No migration needed for given Jest configuration
131-
"
132152
`;
133153

134154
exports[`config migrate should migrate preset if valid preset value is used 2`] = `
135155
""jest": {
136-
"preset": "ts-jest"
156+
"transform": {
157+
"^.+.tsx?$": [
158+
"ts-jest",
159+
{}
160+
]
161+
}
137162
}
138163
"
139164
`;
140165

141166
exports[`config migrate should migrate preset if valid preset value is used 3`] = `
167+
""jest": {
168+
"transform": {
169+
"^.+.tsx?$": [
170+
"ts-jest",
171+
{}
172+
]
173+
}
174+
}
142175
"
143-
No migration needed for given Jest configuration
144-
"
145176
`;
146177

147178
exports[`config migrate should reset testMatch if testRegex is used 1`] = `
148179
""jest": {
149180
"testRegex": "foo-pattern",
150-
"preset": "ts-jest"
181+
"transform": {
182+
"^.+.tsx?$": [
183+
"ts-jest",
184+
{}
185+
]
186+
}
151187
}
152188
"
153189
`;
@@ -157,7 +193,12 @@ exports[`config migrate should reset testMatch if testRegex is used 2`] = `
157193
"testRegex": [
158194
"foo-pattern"
159195
],
160-
"preset": "ts-jest"
196+
"transform": {
197+
"^.+.tsx?$": [
198+
"ts-jest",
199+
{}
200+
]
201+
}
161202
}
162203
"
163204
`;
@@ -168,7 +209,12 @@ exports[`config migrate should reset testMatch if testRegex is used 3`] = `
168209
"testMatch": [
169210
"**/__tests__/**/*.(spec|test).[tj]s?(x)"
170211
],
171-
"preset": "ts-jest"
212+
"transform": {
213+
"^.+.tsx?$": [
214+
"ts-jest",
215+
{}
216+
]
217+
}
172218
}
173219
"
174220
`;
@@ -178,15 +224,25 @@ exports[`config migrate should reset testMatch if testRegex is used 4`] = `
178224
"testMatch": [
179225
"**/__tests__/**/*.(spec|test).[tj]s?(x)"
180226
],
181-
"preset": "ts-jest"
227+
"transform": {
228+
"^.+.tsx?$": [
229+
"ts-jest",
230+
{}
231+
]
232+
}
182233
}
183234
"
184235
`;
185236

186237
exports[`config migrate should reset testMatch if testRegex is used 5`] = `
187238
""jest": {
188239
"testRegex": "foo-pattern",
189-
"preset": "ts-jest"
240+
"transform": {
241+
"^.+.tsx?$": [
242+
"ts-jest",
243+
{}
244+
]
245+
}
190246
}
191247
"
192248
`;

0 commit comments

Comments
 (0)