Skip to content

Commit f60f84e

Browse files
authored
refactor(jest-config)!: do not normalize long deprecated configuration options (#12701)
1 parent d2f03ef commit f60f84e

File tree

9 files changed

+250
-315
lines changed

9 files changed

+250
-315
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- `[jest-config]` [**BREAKING**] Rename `moduleLoader` to `runtime` ([#10817](https://github.com/facebook/jest/pull/10817))
1515
- `[jest-config]` [**BREAKING**] Rename `extraGlobals` to `sandboxInjectedGlobals` ([#10817](https://github.com/facebook/jest/pull/10817))
1616
- `[jest-config]` [**BREAKING**] Throw an error instead of showing a warning if multiple configs are used ([#12510](https://github.com/facebook/jest/pull/12510))
17+
- `[jest-config]` [**BREAKING**] Do not normalize long deprecated configuration options `preprocessorIgnorePatterns`,`scriptPreprocessor`, `setupTestFrameworkScriptFile` and `testPathDirs` ([#1251270110](https://github.com/facebook/jest/pull/12701))
1718
- `[jest-cli, jest-core]` Add `--ignoreProjects` CLI argument to ignore test suites by project name ([#12620](https://github.com/facebook/jest/pull/12620))
1819
- `[jest-core]` Pass project config to `globalSetup`/`globalTeardown` function as second argument ([#12440](https://github.com/facebook/jest/pull/12440))
1920
- `[jest-core]` Stabilize test runners with event emitters ([#12641](https://github.com/facebook/jest/pull/12641))
@@ -38,7 +39,7 @@
3839
- `[jest-mock]` [**BREAKING**] Improve the usage of `jest.fn` generic type argument ([#12489](https://github.com/facebook/jest/pull/12489))
3940
- `[jest-mock]` Add support for auto-mocking async generator functions ([#11080](https://github.com/facebook/jest/pull/11080))
4041
- `[jest-mock]` Add `contexts` member to mock functions ([#12601](https://github.com/facebook/jest/pull/12601))
41-
- `[@jest/reporters]` Add GitHub Actions reporter ([#11320](https://github.com/facebook/jest/pull/11320), [#12658](https://github.com/facebook/jest/pull/12658)
42+
- `[@jest/reporters]` Add GitHub Actions reporter ([#11320](https://github.com/facebook/jest/pull/11320), [#12658](https://github.com/facebook/jest/pull/12658))
4243
- `[@jest/reporters]` Pass `reporterContext` to custom reporter constructors as third argument ([#12657](https://github.com/facebook/jest/pull/12657))
4344
- `[jest-resolve]` [**BREAKING**] Add support for `package.json` `exports` ([#11961](https://github.com/facebook/jest/pull/11961), [#12373](https://github.com/facebook/jest/pull/12373))
4445
- `[jest-resolve]` Support package self-reference ([#12682](https://github.com/facebook/jest/pull/12682))

docs/Configuration.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,12 +1108,6 @@ If you want a path to be [relative to the root directory of your project](#rootd
11081108

11091109
For example, Jest ships with several plug-ins to `jasmine` that work by monkey-patching the jasmine API. If you wanted to add even more jasmine plugins to the mix (or if you wanted some custom, project-wide matchers for example), you could do so in these modules.
11101110

1111-
:::info
1112-
1113-
`setupTestFrameworkScriptFile` is deprecated in favor of `setupFilesAfterEnv`.
1114-
1115-
:::
1116-
11171111
Example `setupFilesAfterEnv` array in a jest.config.js:
11181112

11191113
```js

packages/jest-config/src/Deprecated.ts

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
import chalk = require('chalk');
99
import type {DeprecatedOptions} from 'jest-validate';
10-
import {format as prettyFormat} from 'pretty-format';
11-
12-
const format = (value: unknown) => prettyFormat(value, {min: true});
1310

1411
const deprecatedOptions: DeprecatedOptions = {
1512
browser: () =>
@@ -29,38 +26,24 @@ const deprecatedOptions: DeprecatedOptions = {
2926
3027
Please update your configuration.`,
3128

32-
preprocessorIgnorePatterns: (options: {
29+
preprocessorIgnorePatterns: (_options: {
3330
preprocessorIgnorePatterns?: Array<string>;
3431
}) => ` Option ${chalk.bold(
3532
'"preprocessorIgnorePatterns"',
3633
)} was replaced by ${chalk.bold(
3734
'"transformIgnorePatterns"',
3835
)}, which support multiple preprocessors.
3936
40-
Jest now treats your current configuration as:
41-
{
42-
${chalk.bold('"transformIgnorePatterns"')}: ${chalk.bold(
43-
format(options.preprocessorIgnorePatterns),
44-
)}
45-
}
46-
4737
Please update your configuration.`,
4838

49-
scriptPreprocessor: (options: {
39+
scriptPreprocessor: (_options: {
5040
scriptPreprocessor?: string;
5141
}) => ` Option ${chalk.bold(
5242
'"scriptPreprocessor"',
5343
)} was replaced by ${chalk.bold(
5444
'"transform"',
5545
)}, which support multiple preprocessors.
5646
57-
Jest now treats your current configuration as:
58-
{
59-
${chalk.bold('"transform"')}: ${chalk.bold(
60-
`{".*": ${format(options.scriptPreprocessor)}}`,
61-
)}
62-
}
63-
6447
Please update your configuration.`,
6548

6649
setupTestFrameworkScriptFile: (_options: {
@@ -73,17 +56,12 @@ const deprecatedOptions: DeprecatedOptions = {
7356
7457
Please update your configuration.`,
7558

76-
testPathDirs: (options: {
59+
testPathDirs: (_options: {
7760
testPathDirs?: Array<string>;
7861
}) => ` Option ${chalk.bold('"testPathDirs"')} was replaced by ${chalk.bold(
7962
'"roots"',
8063
)}.
8164
82-
Jest now treats your current configuration as:
83-
{
84-
${chalk.bold('"roots"')}: ${chalk.bold(format(options.testPathDirs))}
85-
}
86-
8765
Please update your configuration.
8866
`,
8967

packages/jest-config/src/__tests__/__snapshots__/normalize.test.ts.snap

Lines changed: 169 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Upgrade help logs a warning when \`scriptPreprocessor\` and/or \`preprocessorIgnorePatterns\` are used 1`] = `
4-
"<yellow><bold><bold>●</><bold> Deprecation Warning</>:</>
5-
<yellow></>
6-
<yellow> Option <bold>"preprocessorIgnorePatterns"</> was replaced by <bold>"transformIgnorePatterns"</>, which support multiple preprocessors.</>
7-
<yellow></>
8-
<yellow> Jest now treats your current configuration as:</>
9-
<yellow> {</>
10-
<yellow> <bold>"transformIgnorePatterns"</>: <bold>["bar/baz", "qux/quux"]</></>
11-
<yellow> }</>
12-
<yellow></>
13-
<yellow> Please update your configuration.</>
14-
<yellow></>
15-
<yellow> <bold>Configuration Documentation:</></>
16-
<yellow> https://jestjs.io/docs/configuration</>
17-
<yellow></>"
18-
`;
19-
203
exports[`displayName generates a default color for the runner jest-runner 1`] = `"yellow"`;
214

225
exports[`displayName generates a default color for the runner jest-runner-eslint 1`] = `"magenta"`;
@@ -132,7 +115,29 @@ exports[`extensionsToTreatAsEsm throws on .mjs 1`] = `
132115
<red></>"
133116
`;
134117

135-
exports[`extraGlobals logs a deprecation warning when \`extraGlobals\` is used 1`] = `
118+
exports[`logs a deprecation warning when 'browser' option is passed 1`] = `
119+
[MockFunction] {
120+
"calls": Array [
121+
Array [
122+
"<yellow><bold><bold>●</><bold> Deprecation Warning</>:</>
123+
<yellow></>
124+
<yellow> Option <bold>"browser"</> has been deprecated. Please install "browser-resolve" and use the "resolver" option in Jest configuration as shown in the documentation: https://jestjs.io/docs/configuration#resolver-string</>
125+
<yellow></>
126+
<yellow> <bold>Configuration Documentation:</></>
127+
<yellow> https://jestjs.io/docs/configuration</>
128+
<yellow></>",
129+
],
130+
],
131+
"results": Array [
132+
Object {
133+
"type": "return",
134+
"value": undefined,
135+
},
136+
],
137+
}
138+
`;
139+
140+
exports[`logs a deprecation warning when 'extraGlobals' option is passed 1`] = `
136141
[MockFunction] {
137142
"calls": Array [
138143
Array [
@@ -156,7 +161,7 @@ exports[`extraGlobals logs a deprecation warning when \`extraGlobals\` is used 1
156161
}
157162
`;
158163

159-
exports[`moduleLoader logs a deprecation warning when \`moduleLoader\` is used 1`] = `
164+
exports[`logs a deprecation warning when 'moduleLoader' option is passed 1`] = `
160165
[MockFunction] {
161166
"calls": Array [
162167
Array [
@@ -180,6 +185,151 @@ exports[`moduleLoader logs a deprecation warning when \`moduleLoader\` is used 1
180185
}
181186
`;
182187

188+
exports[`logs a deprecation warning when 'preprocessorIgnorePatterns' option is passed 1`] = `
189+
[MockFunction] {
190+
"calls": Array [
191+
Array [
192+
"<yellow><bold><bold>●</><bold> Deprecation Warning</>:</>
193+
<yellow></>
194+
<yellow> Option <bold>"preprocessorIgnorePatterns"</> was replaced by <bold>"transformIgnorePatterns"</>, which support multiple preprocessors.</>
195+
<yellow></>
196+
<yellow> Please update your configuration.</>
197+
<yellow></>
198+
<yellow> <bold>Configuration Documentation:</></>
199+
<yellow> https://jestjs.io/docs/configuration</>
200+
<yellow></>",
201+
],
202+
],
203+
"results": Array [
204+
Object {
205+
"type": "return",
206+
"value": undefined,
207+
},
208+
],
209+
}
210+
`;
211+
212+
exports[`logs a deprecation warning when 'scriptPreprocessor' option is passed 1`] = `
213+
[MockFunction] {
214+
"calls": Array [
215+
Array [
216+
"<yellow><bold><bold>●</><bold> Deprecation Warning</>:</>
217+
<yellow></>
218+
<yellow> Option <bold>"scriptPreprocessor"</> was replaced by <bold>"transform"</>, which support multiple preprocessors.</>
219+
<yellow></>
220+
<yellow> Please update your configuration.</>
221+
<yellow></>
222+
<yellow> <bold>Configuration Documentation:</></>
223+
<yellow> https://jestjs.io/docs/configuration</>
224+
<yellow></>",
225+
],
226+
],
227+
"results": Array [
228+
Object {
229+
"type": "return",
230+
"value": undefined,
231+
},
232+
],
233+
}
234+
`;
235+
236+
exports[`logs a deprecation warning when 'setupTestFrameworkScriptFile' option is passed 1`] = `
237+
[MockFunction] {
238+
"calls": Array [
239+
Array [
240+
"<yellow><bold><bold>●</><bold> Deprecation Warning</>:</>
241+
<yellow></>
242+
<yellow> Option <bold>"setupTestFrameworkScriptFile"</> was replaced by configuration <bold>"setupFilesAfterEnv"</>, which supports multiple paths.</>
243+
<yellow></>
244+
<yellow> Please update your configuration.</>
245+
<yellow></>
246+
<yellow> <bold>Configuration Documentation:</></>
247+
<yellow> https://jestjs.io/docs/configuration</>
248+
<yellow></>",
249+
],
250+
],
251+
"results": Array [
252+
Object {
253+
"type": "return",
254+
"value": undefined,
255+
},
256+
],
257+
}
258+
`;
259+
260+
exports[`logs a deprecation warning when 'testPathDirs' option is passed 1`] = `
261+
[MockFunction] {
262+
"calls": Array [
263+
Array [
264+
"<yellow><bold><bold>●</><bold> Deprecation Warning</>:</>
265+
<yellow></>
266+
<yellow> Option <bold>"testPathDirs"</> was replaced by <bold>"roots"</>.</>
267+
<yellow></>
268+
<yellow> Please update your configuration.</>
269+
<yellow> </>
270+
<yellow></>
271+
<yellow> <bold>Configuration Documentation:</></>
272+
<yellow> https://jestjs.io/docs/configuration</>
273+
<yellow></>",
274+
],
275+
],
276+
"results": Array [
277+
Object {
278+
"type": "return",
279+
"value": undefined,
280+
},
281+
],
282+
}
283+
`;
284+
285+
exports[`logs a deprecation warning when 'testURL' option is passed 1`] = `
286+
[MockFunction] {
287+
"calls": Array [
288+
Array [
289+
"<yellow><bold><bold>●</><bold> Deprecation Warning</>:</>
290+
<yellow></>
291+
<yellow> Option <bold>"testURL"</> was replaced by passing the URL via <bold>"testEnvironmentOptions.url"</>.</>
292+
<yellow></>
293+
<yellow> Please update your configuration.</>
294+
<yellow></>
295+
<yellow> <bold>Configuration Documentation:</></>
296+
<yellow> https://jestjs.io/docs/configuration</>
297+
<yellow></>",
298+
],
299+
],
300+
"results": Array [
301+
Object {
302+
"type": "return",
303+
"value": undefined,
304+
},
305+
],
306+
}
307+
`;
308+
309+
exports[`logs a deprecation warning when 'timers' option is passed 1`] = `
310+
[MockFunction] {
311+
"calls": Array [
312+
Array [
313+
"<yellow><bold><bold>●</><bold> Deprecation Warning</>:</>
314+
<yellow></>
315+
<yellow> Option <bold>"timers"</> was replaced by <bold>"fakeTimers"</>.</>
316+
<yellow></>
317+
<yellow> Please update your configuration.</>
318+
<yellow></>
319+
<yellow> <bold>Configuration Documentation:</></>
320+
<yellow> https://jestjs.io/docs/configuration</>
321+
<yellow></>",
322+
],
323+
],
324+
"results": Array [
325+
Object {
326+
"type": "return",
327+
"value": undefined,
328+
},
329+
],
330+
}
331+
`;
332+
183333
exports[`preset throws when module was found but no "jest-preset.js" or "jest-preset.json" files 1`] = `
184334
"<red><bold><bold>● </><bold>Validation Error</>:</>
185335
<red></>
@@ -288,29 +438,6 @@ exports[`runner throw error when a runner is not found 1`] = `
288438
<red></>"
289439
`;
290440

291-
exports[`setupTestFrameworkScriptFile logs a deprecation warning when \`setupTestFrameworkScriptFile\` is used 1`] = `
292-
"<yellow><bold><bold>●</><bold> Deprecation Warning</>:</>
293-
<yellow></>
294-
<yellow> Option <bold>"setupTestFrameworkScriptFile"</> was replaced by configuration <bold>"setupFilesAfterEnv"</>, which supports multiple paths.</>
295-
<yellow></>
296-
<yellow> Please update your configuration.</>
297-
<yellow></>
298-
<yellow> <bold>Configuration Documentation:</></>
299-
<yellow> https://jestjs.io/docs/configuration</>
300-
<yellow></>"
301-
`;
302-
303-
exports[`setupTestFrameworkScriptFile logs an error when \`setupTestFrameworkScriptFile\` and \`setupFilesAfterEnv\` are used 1`] = `
304-
"<red><bold><bold>● </><bold>Validation Error</>:</>
305-
<red></>
306-
<red> Options: <bold>setupTestFrameworkScriptFile</> and <bold>setupFilesAfterEnv</> cannot be used together.</>
307-
<red> Please change your configuration to only use <bold>setupFilesAfterEnv</>.</>
308-
<red></>
309-
<red> <bold>Configuration Documentation:</></>
310-
<red> https://jestjs.io/docs/configuration</>
311-
<red></>"
312-
`;
313-
314441
exports[`testEnvironment throws on invalid environment names 1`] = `
315442
"<red><bold><bold>● </><bold>Validation Error</>:</>
316443
<red></>
@@ -345,54 +472,6 @@ exports[`testTimeout should throw an error if timeout is a negative number 1`] =
345472
<red></>"
346473
`;
347474

348-
exports[`testURL logs a deprecation warning when \`testURL\` is used 1`] = `
349-
[MockFunction] {
350-
"calls": Array [
351-
Array [
352-
"<yellow><bold><bold>●</><bold> Deprecation Warning</>:</>
353-
<yellow></>
354-
<yellow> Option <bold>"testURL"</> was replaced by passing the URL via <bold>"testEnvironmentOptions.url"</>.</>
355-
<yellow></>
356-
<yellow> Please update your configuration.</>
357-
<yellow></>
358-
<yellow> <bold>Configuration Documentation:</></>
359-
<yellow> https://jestjs.io/docs/configuration</>
360-
<yellow></>",
361-
],
362-
],
363-
"results": Array [
364-
Object {
365-
"type": "return",
366-
"value": undefined,
367-
},
368-
],
369-
}
370-
`;
371-
372-
exports[`timers logs a deprecation warning when \`timers\` is used 1`] = `
373-
[MockFunction] {
374-
"calls": Array [
375-
Array [
376-
"<yellow><bold><bold>●</><bold> Deprecation Warning</>:</>
377-
<yellow></>
378-
<yellow> Option <bold>"timers"</> was replaced by <bold>"fakeTimers"</>.</>
379-
<yellow></>
380-
<yellow> Please update your configuration.</>
381-
<yellow></>
382-
<yellow> <bold>Configuration Documentation:</></>
383-
<yellow> https://jestjs.io/docs/configuration</>
384-
<yellow></>",
385-
],
386-
],
387-
"results": Array [
388-
Object {
389-
"type": "return",
390-
"value": undefined,
391-
},
392-
],
393-
}
394-
`;
395-
396475
exports[`watchPlugins throw error when a watch plugin is not found 1`] = `
397476
"<red><bold><bold>● </><bold>Validation Error</>:</>
398477
<red></>

0 commit comments

Comments
 (0)