Skip to content

Commit

Permalink
Make tests pass
Browse files Browse the repository at this point in the history
For unhandled rejection error message change.
  • Loading branch information
MadaraUchiha committed Nov 20, 2017
1 parent a29fe91 commit ba4adc5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
18 changes: 18 additions & 0 deletions test/message/unhandled_promise_trace_warnings.out
Original file line number Diff line number Diff line change
@@ -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 *
Expand Down
7 changes: 5 additions & 2 deletions test/parallel/test-promises-unhandled-proxy-rejections.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
7 changes: 5 additions & 2 deletions test/parallel/test-promises-unhandled-symbol-rejections.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 7 additions & 4 deletions test/parallel/test-promises-warning-on-unhandled-rejection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {})));

0 comments on commit ba4adc5

Please sign in to comment.