From c8362c917e74dfe0033a4ee91fe00c93fc1b7bf5 Mon Sep 17 00:00:00 2001 From: Dylan Greene Date: Thu, 30 Nov 2017 12:25:50 -0500 Subject: [PATCH 1/3] update message and provide current timeout value --- packages/jest-jasmine2/src/__tests__/queue_runner.test.js | 2 +- packages/jest-jasmine2/src/queue_runner.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/jest-jasmine2/src/__tests__/queue_runner.test.js b/packages/jest-jasmine2/src/__tests__/queue_runner.test.js index 21c88980552f..11c5461a37eb 100644 --- a/packages/jest-jasmine2/src/__tests__/queue_runner.test.js +++ b/packages/jest-jasmine2/src/__tests__/queue_runner.test.js @@ -112,7 +112,7 @@ describe('queueRunner', () => { // 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.', + 'by jest.setTimeout: 0ms.', ); expect(fnTwo).toHaveBeenCalled(); }); diff --git a/packages/jest-jasmine2/src/queue_runner.js b/packages/jest-jasmine2/src/queue_runner.js index 6a89309c9834..b7ead27c08fd 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 timeout specified by jest.setTimeout: ' + + timeoutMs + + 'ms.', ); options.onException(error); }, From 82bb0170945de88ac31f312ac4c4f05099f62a8f Mon Sep 17 00:00:00 2001 From: Dylan Greene Date: Thu, 30 Nov 2017 12:42:03 -0500 Subject: [PATCH 2/3] update message and changelog --- CHANGELOG.md | 2 ++ packages/jest-jasmine2/src/__tests__/queue_runner.test.js | 4 ++-- packages/jest-jasmine2/src/queue_runner.js | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) 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/packages/jest-jasmine2/src/__tests__/queue_runner.test.js b/packages/jest-jasmine2/src/__tests__/queue_runner.test.js index 11c5461a37eb..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 jest.setTimeout: 0ms.', + '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 b7ead27c08fd..5e8415405696 100644 --- a/packages/jest-jasmine2/src/queue_runner.js +++ b/packages/jest-jasmine2/src/queue_runner.js @@ -63,9 +63,9 @@ export default function queueRunner(options: Options) { options.setTimeout, () => { const error = new Error( - 'Timeout - Async callback was not invoked within timeout specified by jest.setTimeout: ' + + 'Timeout - Async callback was not invoked within the ' + timeoutMs + - 'ms.', + 'ms timeout specified by jest.setTimeout.', ); options.onException(error); }, From d804786476ffc33a728408030929e197103694d1 Mon Sep 17 00:00:00 2001 From: Dylan Greene Date: Thu, 30 Nov 2017 14:55:01 -0500 Subject: [PATCH 3/3] additional test updates --- integration_tests/__tests__/jasmine_async.test.js | 2 +- integration_tests/__tests__/timeouts.test.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) 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); });