Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Timeout error message to jest.timeout and display current timeout value #4990

Merged
merged 3 commits into from
Nov 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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