Skip to content

Commit

Permalink
Update Timeout error message to jest.timeout and display current ti…
Browse files Browse the repository at this point in the history
…meout value (#4990)

* update message and provide current timeout value

* update message and changelog

* additional test updates
  • Loading branch information
dylang authored and cpojer committed Nov 30, 2017
1 parent 4e2f41f commit 08f8394
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@

### Features

* `[jest-jasmine2]` Update Timeout error message to `jest.timeout` and display current timeout value
([#4990](https://github.com/facebook/jest/pull/4990))
* `[jest-runner]` Enable experimental detection of leaked contexts
([#4895](https://github.com/facebook/jest/pull/4895))
* `[jest-cli]` Add combined coverage threshold for directories.
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/__tests__/jasmine_async.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('async jasmine', () => {

const {message} = json.testResults[0];
expect(message).toMatch('with failing timeout');
expect(message).toMatch('Async callback was not invoked within timeout');
expect(message).toMatch('Async callback was not invoked within');
expect(message).toMatch('done - with error thrown');
expect(message).toMatch('done - with error called back');
});
Expand Down
4 changes: 3 additions & 1 deletion integration_tests/__tests__/timeouts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ test('exceeds the timeout', () => {

const {stderr, status} = runJest(DIR, ['-w=1', '--ci=false']);
const {rest, summary} = extractSummary(stderr);
expect(rest).toMatch(/(jasmine\.DEFAULT_TIMEOUT_INTERVAL|Exceeded timeout)/);
expect(rest).toMatch(
/(jest\.setTimeout|jasmine\.DEFAULT_TIMEOUT_INTERVAL|Exceeded timeout)/,
);
expect(summary).toMatchSnapshot();
expect(status).toBe(1);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-jasmine2/src/__tests__/queue_runner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ describe('queueRunner', () => {
expect(onException).toHaveBeenCalled();
// i.e. the `message` of the error passed to `onException`.
expect(onException.mock.calls[0][0].message).toEqual(
'Timeout - Async callback was not invoked within timeout specified ' +
'by jasmine.DEFAULT_TIMEOUT_INTERVAL.',
'Timeout - Async callback was not invoked within the 0ms timeout ' +
'specified by jest.setTimeout.',
);
expect(fnTwo).toHaveBeenCalled();
});
Expand Down
8 changes: 5 additions & 3 deletions packages/jest-jasmine2/src/queue_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@ export default function queueRunner(options: Options) {
if (!timeout) {
return promise;
}
const timeoutMs: number = timeout();
return pTimeout(
promise,
timeout(),
timeoutMs,
options.clearTimeout,
options.setTimeout,
() => {
const error = new Error(
'Timeout - Async callback was not invoked within timeout specified ' +
'by jasmine.DEFAULT_TIMEOUT_INTERVAL.',
'Timeout - Async callback was not invoked within the ' +
timeoutMs +
'ms timeout specified by jest.setTimeout.',
);
options.onException(error);
},
Expand Down

0 comments on commit 08f8394

Please sign in to comment.