Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,8 @@ function expectsNoError(stackStartFn, actual, error, message) {
actual,
expected: error,
operator: stackStartFn.name,
message: `Got unwanted ${fnType}${details}\n${actual && actual.message}`,
message: `Got unwanted ${fnType}${details}\n` +
`Actual message: "${actual && actual.message}"`,
stackStartFn
});
}
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-assert-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ common.crashOnUnhandledRejection();
assert(err instanceof assert.AssertionError,
`${err.name} is not instance of AssertionError`);
assert.strictEqual(err.code, 'ERR_ASSERTION');
assert(/^Got unwanted rejection\.\n$/.test(err.message));
assert.strictEqual(err.message,
'Got unwanted rejection.\nActual message: ""');
assert.strictEqual(err.operator, 'doesNotReject');
assert.ok(!err.stack.includes('at Function.doesNotReject'));
return true;
Expand Down
25 changes: 9 additions & 16 deletions test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,29 +124,22 @@ assert.throws(() => thrower(TypeError));
assert.ok(threw, 'a.doesNotThrow is not catching type matching errors');
}

common.expectsError(
assert.throws(
() => a.doesNotThrow(() => thrower(Error), 'user message'),
{
type: a.AssertionError,
name: 'AssertionError [ERR_ASSERTION]',
code: 'ERR_ASSERTION',
operator: 'doesNotThrow',
message: 'Got unwanted exception: user message\n[object Object]'
message: 'Got unwanted exception: user message\n' +
'Actual message: "[object Object]"'
}
);

common.expectsError(
() => a.doesNotThrow(() => thrower(Error), 'user message'),
{
code: 'ERR_ASSERTION',
message: /Got unwanted exception: user message\n\[object Object\]/
}
);

common.expectsError(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated test case.

assert.throws(
() => a.doesNotThrow(() => thrower(Error)),
{
code: 'ERR_ASSERTION',
message: /Got unwanted exception\.\n\[object Object\]/
message: 'Got unwanted exception.\nActual message: "[object Object]"'
}
);

Expand Down Expand Up @@ -833,13 +826,13 @@ common.expectsError(

// eslint-disable-next-line no-throw-literal
assert.throws(() => { throw undefined; }, /undefined/);
common.expectsError(
assert.throws(
// eslint-disable-next-line no-throw-literal
() => a.doesNotThrow(() => { throw undefined; }),
{
type: assert.AssertionError,
name: 'AssertionError [ERR_ASSERTION]',
code: 'ERR_ASSERTION',
message: 'Got unwanted exception.\nundefined'
message: 'Got unwanted exception.\nActual message: "undefined"'
}
);
}