Skip to content

Commit 4488cb9

Browse files
committed
refactor: rename timeout to testTimeout
1 parent a8bbaf7 commit 4488cb9

File tree

14 files changed

+39
-34
lines changed

14 files changed

+39
-34
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Features
44

5-
- `[*]` Manage the global timeout with `--timeout` command line argument. ([#8456](https://github.com/facebook/jest/pull/8456))
5+
- `[*]` Manage the global test timeout with `--testTimeout` command line argument. ([#8456](https://github.com/facebook/jest/pull/8456))
66

77
### Fixes
88

TestUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const DEFAULT_GLOBAL_CONFIG: Config.GlobalConfig = {
5555
testNamePattern: '',
5656
testPathPattern: '',
5757
testResultsProcessor: null,
58-
timeout: 5000,
58+
testTimeout: 5000,
5959
updateSnapshot: 'none',
6060
useStderr: false,
6161
verbose: false,

docs/CLI.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,9 @@ Lets you specify a custom test runner.
301301

302302
Lets you specify a custom test sequencer. Please refer to the documentation of the corresponding configuration property for details.
303303

304-
### `--timeout=<number>`
304+
### `--testTimeout=<number>`
305305

306-
Default timeout of the test case. If the value is 0 then the timeout is 1 193 days.
306+
Default timeout of a test. If the value is 0 then the timeout is ~1 193 days.
307307

308308
### `--updateSnapshot`
309309

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,33 @@ Time: <<REPLACED>>
2121
Ran all test suites.
2222
`;
2323
24-
exports[`exceeds the command line timeout 1`] = `
24+
exports[`exceeds the command line testTimeout 1`] = `
2525
Test Suites: 1 failed, 1 total
2626
Tests: 1 failed, 1 total
2727
Snapshots: 0 total
2828
Time: <<REPLACED>>
2929
Ran all test suites.
3030
`;
3131
32-
exports[`does not exceed the command line timeout 1`] = `
32+
exports[`does not exceed the command line testTimeout 1`] = `
3333
PASS __tests__/a-banana.js
3434
✓ banana
3535
`;
3636
37-
exports[`does not exceed the command line timeout 2`] = `
37+
exports[`does not exceed the command line testTimeout 2`] = `
3838
Test Suites: 1 passed, 1 total
3939
Tests: 1 passed, 1 total
4040
Snapshots: 0 total
4141
Time: <<REPLACED>>
4242
Ran all test suites.
4343
`;
4444
45-
exports[`if command line timeout=0 its mean no timeout 1`] = `
45+
exports[`if command line timeout=0 its mean no testTimeout 1`] = `
4646
PASS __tests__/a-banana.js
4747
✓ banana
4848
`;
4949
50-
exports[`if command line timeout=0 its mean no timeout 2`] = `
50+
exports[`if command line timeout=0 its mean no testTimeout 2`] = `
5151
Test Suites: 1 passed, 1 total
5252
Tests: 1 passed, 1 total
5353
Snapshots: 0 total

e2e/__tests__/timeouts.test.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ test('does not exceed the timeout', () => {
6161
expect(status).toBe(0);
6262
});
6363

64-
test('exceeds the command line timeout', () => {
64+
test('exceeds the command line testTimeout', () => {
6565
writeFiles(DIR, {
6666
'__tests__/a-banana.js': `
6767
@@ -77,7 +77,7 @@ test('exceeds the command line timeout', () => {
7777
const {stderr, status} = runJest(DIR, [
7878
'-w=1',
7979
'--ci=false',
80-
'--timeout=200',
80+
'--testTimeout=200',
8181
]);
8282
const {rest, summary} = extractSummary(stderr);
8383
expect(rest).toMatch(
@@ -87,7 +87,7 @@ test('exceeds the command line timeout', () => {
8787
expect(status).toBe(1);
8888
});
8989

90-
test('does not exceed the command line timeout', () => {
90+
test('does not exceed the command line testTimeout', () => {
9191
writeFiles(DIR, {
9292
'__tests__/a-banana.js': `
9393
@@ -103,15 +103,15 @@ test('does not exceed the command line timeout', () => {
103103
const {stderr, status} = runJest(DIR, [
104104
'-w=1',
105105
'--ci=false',
106-
'--timeout=1000',
106+
'--testTimeout=1000',
107107
]);
108108
const {rest, summary} = extractSummary(stderr);
109109
expect(wrap(rest)).toMatchSnapshot();
110110
expect(wrap(summary)).toMatchSnapshot();
111111
expect(status).toBe(0);
112112
});
113113

114-
test('if command line timeout=0 its mean no timeout', () => {
114+
test('if command line timeout=0 its mean no testTimeout', () => {
115115
writeFiles(DIR, {
116116
'__tests__/a-banana.js': `
117117
@@ -124,7 +124,11 @@ test('if command line timeout=0 its mean no timeout', () => {
124124
'package.json': '{}',
125125
});
126126

127-
const {stderr, status} = runJest(DIR, ['-w=1', '--ci=false', '--timeout=0']);
127+
const {stderr, status} = runJest(DIR, [
128+
'-w=1',
129+
'--ci=false',
130+
'--testTimeout=0',
131+
]);
128132
const {rest, summary} = extractSummary(stderr);
129133
expect(wrap(rest)).toMatchSnapshot();
130134
expect(wrap(summary)).toMatchSnapshot();

packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapterInit.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ export const initialize = ({
4747
testPath: Config.Path;
4848
parentProcess: Process;
4949
}) => {
50-
if (globalConfig.timeout) getRunnerState().testTimeout = globalConfig.timeout;
50+
if (globalConfig.testTimeout)
51+
getRunnerState().testTimeout = globalConfig.testTimeout;
5152

5253
const mutex = throat(globalConfig.maxConcurrency);
5354

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -622,16 +622,16 @@ export const options = {
622622
'provided: `<rootDir>/path/to/testSequencer.js`',
623623
type: 'string' as 'string',
624624
},
625-
testURL: {
626-
description: 'This option sets the URL for the jsdom environment.',
627-
type: 'string' as 'string',
628-
},
629-
timeout: {
625+
testTimeout: {
630626
description:
631627
'This option sets the default timeouts of test cases.' +
632628
"If you don't want timeout set it to 0",
633629
type: 'number' as 'number',
634630
},
631+
testURL: {
632+
description: 'This option sets the URL for the jsdom environment.',
633+
type: 'string' as 'string',
634+
},
635635
timers: {
636636
description:
637637
'Setting this value to fake allows the use of fake timers ' +

packages/jest-config/src/ValidConfig.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ const initialOptions: Config.InitialOptions = {
113113
testResultsProcessor: 'processor-node-module',
114114
testRunner: 'jasmine2',
115115
testSequencer: '@jest/test-sequencer',
116+
testTimeout: 5000,
116117
testURL: 'http://localhost',
117-
timeout: 5000,
118118
timers: 'real',
119119
transform: {
120120
'^.+\\.js$': '<rootDir>/preprocessor.js',

packages/jest-config/src/__tests__/normalize.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1563,18 +1563,18 @@ describe('displayName', () => {
15631563
);
15641564
});
15651565

1566-
describe('timeout', () => {
1566+
describe('testTimeout', () => {
15671567
it('should return timeout value if defined', () => {
15681568
console.warn.mockImplementation(() => {});
1569-
const {options} = normalize({rootDir: '/root/', timeout: 1000}, {});
1569+
const {options} = normalize({rootDir: '/root/', testTimeout: 1000}, {});
15701570

1571-
expect(options.timeout).toBe(1000);
1571+
expect(options.testTimeout).toBe(1000);
15721572
expect(console.warn).not.toHaveBeenCalled();
15731573
});
15741574

15751575
it('should return with 2^32 -1 if timeout=0', () => {
1576-
const {options} = normalize({rootDir: '/root/', timeout: 0}, {});
1576+
const {options} = normalize({rootDir: '/root/', testTimeout: 0}, {});
15771577

1578-
expect(options.timeout).toBe(Math.pow(2, 31) - 1);
1578+
expect(options.testTimeout).toBe(Math.pow(2, 31) - 1);
15791579
});
15801580
});

packages/jest-config/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ const groupOptions = (
149149
testPathPattern: options.testPathPattern,
150150
testResultsProcessor: options.testResultsProcessor,
151151
testSequencer: options.testSequencer,
152-
timeout: options.timeout,
152+
testTimeout: options.testTimeout,
153153
updateSnapshot: options.updateSnapshot,
154154
useStderr: options.useStderr,
155155
verbose: options.verbose,

packages/jest-config/src/normalize.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ export default function normalize(
790790
value = oldOptions[key];
791791
break;
792792
}
793-
case 'timeout': {
793+
case 'testTimeout': {
794794
value =
795795
oldOptions[key] === 0 ? MAX_32_BIT_SIGNED_INTEGER : oldOptions[key];
796796
break;

packages/jest-core/src/lib/__tests__/__snapshots__/log_debug_messages.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ exports[`prints the config object 1`] = `
112112
"testNamePattern": "",
113113
"testPathPattern": "",
114114
"testResultsProcessor": null,
115-
"timeout": 5000,
115+
"testTimeout": 5000,
116116
"updateSnapshot": "none",
117117
"useStderr": false,
118118
"verbose": false,

packages/jest-jasmine2/src/jasmine/jasmineLight.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import Timer from './Timer';
4343
const create = function(createOptions: Record<string, any>): Jasmine {
4444
const j$ = {...createOptions} as Jasmine;
4545

46-
j$._DEFAULT_TIMEOUT_INTERVAL = createOptions.globalConfig.timeout || 5000;
46+
j$._DEFAULT_TIMEOUT_INTERVAL = createOptions.globalConfig.testTimeout || 5000;
4747

4848
j$.getEnv = function(options?: object) {
4949
const env = (j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options));

packages/jest-types/src/Config.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export type InitialOptions = {
207207
testRunner?: string;
208208
testSequencer?: string;
209209
testURL?: string;
210-
timeout?: number;
210+
testTimeout?: number;
211211
timers?: 'real' | 'fake';
212212
transform?: {
213213
[key: string]: string;
@@ -345,7 +345,7 @@ export type GlobalConfig = {
345345
testPathPattern: string;
346346
testResultsProcessor: string | null | undefined;
347347
testSequencer: string;
348-
timeout: number;
348+
testTimeout: number;
349349
updateSnapshot: SnapshotUpdateState;
350350
useStderr: boolean;
351351
verbose: boolean | null | undefined;
@@ -491,7 +491,7 @@ export type Argv = Arguments<
491491
testRunner: string;
492492
testSequencer: string;
493493
testURL: string;
494-
timeout: number | null | undefined;
494+
testTimeout: number | null | undefined;
495495
timers: string;
496496
transform: string;
497497
transformIgnorePatterns: Array<string>;

0 commit comments

Comments
 (0)