Skip to content

Commit

Permalink
fixup: remove now obsolete code
Browse files Browse the repository at this point in the history
  • Loading branch information
BridgeAR committed Apr 19, 2018
1 parent e72a028 commit 8a76c1a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
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

0 comments on commit 8a76c1a

Please sign in to comment.