From ba4adc55f8c5a7ee2879ba9f544bb336e755276d Mon Sep 17 00:00:00 2001 From: Madara Uchiha Date: Mon, 20 Nov 2017 21:23:06 +0200 Subject: [PATCH] Make tests pass For unhandled rejection error message change. --- .../unhandled_promise_trace_warnings.out | 18 ++++++++++++++++++ ...test-promises-unhandled-proxy-rejections.js | 7 +++++-- ...est-promises-unhandled-symbol-rejections.js | 7 +++++-- ...-promises-warning-on-unhandled-rejection.js | 11 +++++++---- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/test/message/unhandled_promise_trace_warnings.out b/test/message/unhandled_promise_trace_warnings.out index 77e7edcf4c6d88..410b3bf4e36d41 100644 --- a/test/message/unhandled_promise_trace_warnings.out +++ b/test/message/unhandled_promise_trace_warnings.out @@ -1,3 +1,21 @@ +(node:*) UnhandledPromiseRejectionWarning: Error: This was rejected + at * (*test*message*unhandled_promise_trace_warnings.js:*) + at * + at * + at * + at * + at * + at * + at * + at * + at * + at * + at * + at * + at * + at * + at * + at * (node:*) Error: This was rejected at * (*test*message*unhandled_promise_trace_warnings.js:*) at * diff --git a/test/parallel/test-promises-unhandled-proxy-rejections.js b/test/parallel/test-promises-unhandled-proxy-rejections.js index 91808af14588d3..f632857d6373ba 100644 --- a/test/parallel/test-promises-unhandled-proxy-rejections.js +++ b/test/parallel/test-promises-unhandled-proxy-rejections.js @@ -6,8 +6,11 @@ const expectedDeprecationWarning = 'Unhandled promise rejections are ' + 'rejections that are not handled will ' + 'terminate the Node.js process with a ' + 'non-zero exit code.'; -const expectedPromiseWarning = 'Unhandled promise rejection (rejection id: ' + - '1): [object Object]'; +const expectedPromiseWarning = 'Unhandled promise rejection. ' + + 'This error originated either by throwing ' + + 'inside of an async function without a catch ' + + 'block, or by rejecting a promise which was ' + + 'not handled with .catch(). (rejection id: 1)'; function throwErr() { throw new Error('Error from proxy'); diff --git a/test/parallel/test-promises-unhandled-symbol-rejections.js b/test/parallel/test-promises-unhandled-symbol-rejections.js index a60a5f2e8aac30..3e06d7edad27b4 100644 --- a/test/parallel/test-promises-unhandled-symbol-rejections.js +++ b/test/parallel/test-promises-unhandled-symbol-rejections.js @@ -6,8 +6,11 @@ const expectedDeprecationWarning = 'Unhandled promise rejections are ' + 'rejections that are not handled will ' + 'terminate the Node.js process with a ' + 'non-zero exit code.'; -const expectedPromiseWarning = 'Unhandled promise rejection (rejection id: ' + - '1): Symbol()'; +const expectedPromiseWarning = 'Unhandled promise rejection. ' + + 'This error originated either by throwing ' + + 'inside of an async function without a catch ' + + 'block, or by rejecting a promise which was ' + + 'not handled with .catch(). (rejection id: 1)'; common.expectWarning({ DeprecationWarning: expectedDeprecationWarning, diff --git a/test/parallel/test-promises-warning-on-unhandled-rejection.js b/test/parallel/test-promises-warning-on-unhandled-rejection.js index 10f95162a09597..0e16ef58438f10 100644 --- a/test/parallel/test-promises-warning-on-unhandled-rejection.js +++ b/test/parallel/test-promises-warning-on-unhandled-rejection.js @@ -12,18 +12,21 @@ let b = 0; process.on('warning', common.mustCall((warning) => { switch (b++) { case 0: - assert.strictEqual(warning.name, 'UnhandledPromiseRejectionWarning'); - assert(/Unhandled promise rejection/.test(warning.message)); + assert.strictEqual(warning.message, 'This was rejected'); break; case 1: - assert.strictEqual(warning.name, 'DeprecationWarning'); + assert.strictEqual(warning.name, 'UnhandledPromiseRejectionWarning'); + assert(/Unhandled promise rejection/.test(warning.message), 'Expected warning message to contain "Unhandled promise rejection" but did not. Had "' + warning.message + '" instead.'); break; case 2: + assert.strictEqual(warning.name, 'DeprecationWarning'); + break; + case 3: assert.strictEqual(warning.name, 'PromiseRejectionHandledWarning'); assert(/Promise rejection was handled asynchronously/ .test(warning.message)); } -}, 3)); +}, 4)); const p = Promise.reject('This was rejected'); setImmediate(common.mustCall(() => p.catch(() => {})));