Skip to content

Commit 08f8394

Browse files
dylangcpojer
authored andcommitted
Update Timeout error message to jest.timeout and display current timeout value (#4990)
* update message and provide current timeout value * update message and changelog * additional test updates
1 parent 4e2f41f commit 08f8394

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151

5252
### Features
5353

54+
* `[jest-jasmine2]` Update Timeout error message to `jest.timeout` and display current timeout value
55+
([#4990](https://github.com/facebook/jest/pull/4990))
5456
* `[jest-runner]` Enable experimental detection of leaked contexts
5557
([#4895](https://github.com/facebook/jest/pull/4895))
5658
* `[jest-cli]` Add combined coverage threshold for directories.

integration_tests/__tests__/jasmine_async.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('async jasmine', () => {
2525

2626
const {message} = json.testResults[0];
2727
expect(message).toMatch('with failing timeout');
28-
expect(message).toMatch('Async callback was not invoked within timeout');
28+
expect(message).toMatch('Async callback was not invoked within');
2929
expect(message).toMatch('done - with error thrown');
3030
expect(message).toMatch('done - with error called back');
3131
});

integration_tests/__tests__/timeouts.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ test('exceeds the timeout', () => {
3636

3737
const {stderr, status} = runJest(DIR, ['-w=1', '--ci=false']);
3838
const {rest, summary} = extractSummary(stderr);
39-
expect(rest).toMatch(/(jasmine\.DEFAULT_TIMEOUT_INTERVAL|Exceeded timeout)/);
39+
expect(rest).toMatch(
40+
/(jest\.setTimeout|jasmine\.DEFAULT_TIMEOUT_INTERVAL|Exceeded timeout)/,
41+
);
4042
expect(summary).toMatchSnapshot();
4143
expect(status).toBe(1);
4244
});

packages/jest-jasmine2/src/__tests__/queue_runner.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ describe('queueRunner', () => {
111111
expect(onException).toHaveBeenCalled();
112112
// i.e. the `message` of the error passed to `onException`.
113113
expect(onException.mock.calls[0][0].message).toEqual(
114-
'Timeout - Async callback was not invoked within timeout specified ' +
115-
'by jasmine.DEFAULT_TIMEOUT_INTERVAL.',
114+
'Timeout - Async callback was not invoked within the 0ms timeout ' +
115+
'specified by jest.setTimeout.',
116116
);
117117
expect(fnTwo).toHaveBeenCalled();
118118
});

packages/jest-jasmine2/src/queue_runner.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,17 @@ export default function queueRunner(options: Options) {
5555
if (!timeout) {
5656
return promise;
5757
}
58+
const timeoutMs: number = timeout();
5859
return pTimeout(
5960
promise,
60-
timeout(),
61+
timeoutMs,
6162
options.clearTimeout,
6263
options.setTimeout,
6364
() => {
6465
const error = new Error(
65-
'Timeout - Async callback was not invoked within timeout specified ' +
66-
'by jasmine.DEFAULT_TIMEOUT_INTERVAL.',
66+
'Timeout - Async callback was not invoked within the ' +
67+
timeoutMs +
68+
'ms timeout specified by jest.setTimeout.',
6769
);
6870
options.onException(error);
6971
},

0 commit comments

Comments
 (0)