Skip to content

Commit 0523bcc

Browse files
authored
feat: remove testURL option, can be set in testEnvironmentOptions (#10797)
1 parent c7da417 commit 0523bcc

File tree

21 files changed

+91
-55
lines changed

21 files changed

+91
-55
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- `[babel-jest]` Export `createTransformer` function ([#12399](https://github.com/facebook/jest/pull/12399))
66
- `[expect]` Expose `AsymmetricMatchers`, `MatcherFunction` and `MatcherFunctionWithState` interfaces ([#12363](https://github.com/facebook/jest/pull/12363), [#12376](https://github.com/facebook/jest/pull/12376))
7+
- `[jest-cli, jest-config]` [**BREAKING**] Remove `testURL` config, use `testEnvironmentOptions.url` instead ([#10797](https://github.com/facebook/jest/pull/10797))
78
- `[jest-config]` [**BREAKING**] Stop shipping `jest-environment-jsdom` by default ([#12354](https://github.com/facebook/jest/pull/12354))
89
- `[jest-config]` [**BREAKING**] Stop shipping `jest-jasmine2` by default ([#12355](https://github.com/facebook/jest/pull/12355))
910
- `[jest-config, @jest/types]` Add `ci` to `GlobalConfig` ([#12378](https://github.com/facebook/jest/pull/12378))

docs/Configuration.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ beforeAll(() => {
11681168

11691169
Default: `{}`
11701170

1171-
Test environment options that will be passed to the `testEnvironment`. The relevant options depend on the environment. For example, you can override options given to [jsdom](https://github.com/jsdom/jsdom) such as `{html: "<html lang="zh-cmn-Hant"></html>", userAgent: "Agent/007"}`.
1171+
Test environment options that will be passed to the `testEnvironment`. The relevant options depend on the environment. For example, you can override options given to [`jsdom`](https://github.com/jsdom/jsdom) such as `{html: "<html lang="zh-cmn-Hant"></html>", url: 'https://jestjs.io/', userAgent: "Agent/007"}`.
11721172

11731173
### `testFailureExitCode` \[number]
11741174

@@ -1332,12 +1332,6 @@ Default: `5000`
13321332

13331333
Default timeout of a test in milliseconds.
13341334

1335-
### `testURL` \[string]
1336-
1337-
Default: `http://localhost`
1338-
1339-
This option sets the URL for the jsdom environment. It is reflected in properties such as `location.href`.
1340-
13411335
### `timers` \[string]
13421336

13431337
Default: `real`

e2e/__tests__/__snapshots__/showConfig.test.ts.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ exports[`--showConfig outputs config info and exits 1`] = `
6666
],
6767
"testRegex": [],
6868
"testRunner": "<<REPLACED_JEST_PACKAGES_DIR>>/jest-circus/runner.js",
69-
"testURL": "http://localhost",
7069
"timers": "real",
7170
"transform": [
7271
[

packages/jest-cli/src/cli/args.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,10 +616,6 @@ export const options = {
616616
description: 'This option sets the default timeouts of test cases.',
617617
type: 'number',
618618
},
619-
testURL: {
620-
description: 'This option sets the URL for the jsdom environment.',
621-
type: 'string',
622-
},
623619
timers: {
624620
description:
625621
'Setting this value to fake allows the use of fake timers ' +

packages/jest-cli/src/init/__tests__/__snapshots__/init.test.js.snap

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,6 @@ module.exports = {
283283
// This option allows use of a custom test runner
284284
// testRunner: "jest-circus/runner",
285285
286-
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
287-
// testURL: "http://localhost",
288-
289286
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
290287
// timers: "real",
291288

packages/jest-config/src/Defaults.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ const defaultOptions: Config.DefaultOptions = {
7272
testRegex: [],
7373
testRunner: 'jest-circus/runner',
7474
testSequencer: '@jest/test-sequencer',
75-
testURL: 'http://localhost',
7675
timers: 'real',
7776
transformIgnorePatterns: [NODE_MODULES_REGEXP, `\\.pnp\\.[^\\${sep}]+$`],
7877
useStderr: false,

packages/jest-config/src/Deprecated.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ const deprecatedOptions: DeprecatedOptions = {
7474
7575
Please update your configuration.
7676
`,
77+
78+
testURL: (_options: {testURL?: string}) => ` Option ${chalk.bold(
79+
'"testURL"',
80+
)} was replaced by passing the URL via ${chalk.bold(
81+
'"testEnvironmentOptions.url"',
82+
)}.
83+
84+
Please update your configuration.`,
7785
};
7886

7987
export default deprecatedOptions;

packages/jest-config/src/Descriptions.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ const descriptions: {[key in keyof Config.InitialOptions]: string} = {
8484
testResultsProcessor:
8585
'This option allows the use of a custom results processor',
8686
testRunner: 'This option allows use of a custom test runner',
87-
testURL:
88-
'This option sets the URL for the jsdom environment. It is reflected in properties such as location.href',
8987
timers:
9088
'Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"',
9189
transform: 'A map from regular expressions to paths to transformers',

packages/jest-config/src/ValidConfig.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ const initialOptions: Config.InitialOptions = {
115115
snapshotResolver: '<rootDir>/snapshotResolver.js',
116116
snapshotSerializers: ['my-serializer-module'],
117117
testEnvironment: 'jest-environment-node',
118-
testEnvironmentOptions: {userAgent: 'Agent/007'},
118+
testEnvironmentOptions: {
119+
url: 'http://localhost',
120+
userAgent: 'Agent/007',
121+
},
119122
testFailureExitCode: 1,
120123
testLocationInResults: false,
121124
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
@@ -129,7 +132,6 @@ const initialOptions: Config.InitialOptions = {
129132
testRunner: 'circus',
130133
testSequencer: '@jest/test-sequencer',
131134
testTimeout: 5000,
132-
testURL: 'http://localhost',
133135
timers: 'real',
134136
transform: {
135137
'\\.js$': '<rootDir>/preprocessor.js',

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,30 @@ exports[`testTimeout should throw an error if timeout is a negative number 1`] =
229229
<red></>"
230230
`;
231231

232+
exports[`testURL logs a deprecation warning when \`testURL\` is used 1`] = `
233+
[MockFunction] {
234+
"calls": Array [
235+
Array [
236+
"<yellow><bold><bold>●</><bold> Deprecation Warning</>:</>
237+
<yellow></>
238+
<yellow> Option <bold>"testURL"</> was replaced by passing the URL via <bold>"testEnvironmentOptions.url"</>.</>
239+
<yellow></>
240+
<yellow> Please update your configuration.</>
241+
<yellow></>
242+
<yellow> <bold>Configuration Documentation:</></>
243+
<yellow> https://jestjs.io/docs/configuration</>
244+
<yellow></>",
245+
],
246+
],
247+
"results": Array [
248+
Object {
249+
"type": "return",
250+
"value": undefined,
251+
},
252+
],
253+
}
254+
`;
255+
232256
exports[`watchPlugins throw error when a watch plugin is not found 1`] = `
233257
"<red><bold><bold>● </><bold>Validation Error</>:</>
234258
<red></>

0 commit comments

Comments
 (0)