Skip to content

Commit bc326bd

Browse files
committed
consistent error messaging for rejected promises
If a test is rejected with a non-Error reason an AssertionError is created. Like when a non-Error is thrown, use inspect() to include a string representation of the rejection reason.
1 parent 5710e65 commit bc326bd

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ Test.prototype.run = function () {
161161
if (!(err instanceof Error)) {
162162
err = new assert.AssertionError({
163163
actual: err,
164-
message: 'Promise rejected with "' + err + '"',
164+
message: 'Promise rejected with: ' + inspect(err, {depth: null}),
165165
operator: 'promise'
166166
});
167167
}

test/promise.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ test('reject with non-Error', function (t) {
318318
}).run().then(function (result) {
319319
t.is(result.passed, false);
320320
t.is(result.reason.name, 'AssertionError');
321-
t.is(result.reason.message, 'Promise rejected with "failure"');
321+
t.is(result.reason.message, 'Promise rejected with: \'failure\'');
322322
t.end();
323323
});
324324
});

0 commit comments

Comments
 (0)