diff --git a/CHANGELOG.md b/CHANGELOG.md index 325099eedc0c..b63f4080965a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/integration_tests/__tests__/jasmine_async.test.js b/integration_tests/__tests__/jasmine_async.test.js index 809f1105049c..ba5e40af88e9 100644 --- a/integration_tests/__tests__/jasmine_async.test.js +++ b/integration_tests/__tests__/jasmine_async.test.js @@ -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'); }); diff --git a/integration_tests/__tests__/timeouts.test.js b/integration_tests/__tests__/timeouts.test.js index 8bde759b02ee..53af436276b0 100644 --- a/integration_tests/__tests__/timeouts.test.js +++ b/integration_tests/__tests__/timeouts.test.js @@ -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); }); diff --git a/packages/jest-jasmine2/src/__tests__/queue_runner.test.js b/packages/jest-jasmine2/src/__tests__/queue_runner.test.js index 21c88980552f..516604a0156a 100644 --- a/packages/jest-jasmine2/src/__tests__/queue_runner.test.js +++ b/packages/jest-jasmine2/src/__tests__/queue_runner.test.js @@ -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(); }); diff --git a/packages/jest-jasmine2/src/queue_runner.js b/packages/jest-jasmine2/src/queue_runner.js index 6a89309c9834..5e8415405696 100644 --- a/packages/jest-jasmine2/src/queue_runner.js +++ b/packages/jest-jasmine2/src/queue_runner.js @@ -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); },