Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fixup: remove now obsolete code
  • Loading branch information
BridgeAR committed Apr 19, 2018
commit 8a76c1a1fffaf343b175c78e8f55a619ae71140b
21 changes: 9 additions & 12 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,6 @@ exports.expectsError = function expectsError(fn, settings, exact) {
if (type !== Error && !Error.isPrototypeOf(type)) {
throw new TypeError('`settings.type` must inherit from `Error`');
}
assert(error instanceof type,
`${error.name} is not instance of ${type.name}`);
let constructor = error.constructor;
if (constructor.name === 'NodeError' && type.name !== 'NodeError') {
constructor = Object.getPrototypeOf(error.constructor);
Expand All @@ -729,14 +727,14 @@ exports.expectsError = function expectsError(fn, settings, exact) {
error.type = constructor;
}

if ('message' in settings && typeof settings.message === 'object') {
if (settings.message.test(error.message)) {
// Make a copy so we are able to modify the settings.
innerSettings = Object.create(
settings, Object.getOwnPropertyDescriptors(settings));
// Visualize the message as identical in case of other errors.
innerSettings.message = error.message;
}
if ('message' in settings &&
typeof settings.message === 'object' &&
settings.message.test(error.message)) {
// Make a copy so we are able to modify the settings.
innerSettings = Object.create(
settings, Object.getOwnPropertyDescriptors(settings));
// Visualize the message as identical in case of other errors.
innerSettings.message = error.message;
}

// Check all error properties.
Expand All @@ -753,8 +751,7 @@ exports.expectsError = function expectsError(fn, settings, exact) {
actual: a,
expected: b,
operator: 'strictEqual',
stackStartFn: assert.throws,
errorDiff: 2
stackStartFn: assert.throws
});
Error.stackTraceLimit = tmpLimit;

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-internal-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ common.expectsError(() => {
}, { code: 'TEST_ERROR_1', type: RangeError });
}, {
code: 'ERR_ASSERTION',
message: /^.+ is not instance of \S/
message: /- type: \[Function: TypeError]\n\+ type: \[Function: RangeError]/
});

common.expectsError(() => {
Expand Down