Skip to content

Commit

Permalink
test: improve assertion fail messages
Browse files Browse the repository at this point in the history
PR-URL: #14949
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
refack authored and MylesBorins committed Sep 12, 2017
1 parent 57c7eae commit eb46609
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions test/parallel/test-stream-inheritance.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,26 @@ assert.ok(!(undefined instanceof Writable));

// Simple inheritance check for `Writable` works fine in a subclass constructor.
function CustomWritable() {
assert.ok(this instanceof Writable, 'inherits from Writable');
assert.ok(this instanceof CustomWritable, 'inherits from CustomWritable');
assert.ok(
this instanceof CustomWritable,
`${this} does not inherit from CustomWritable`
);
assert.ok(
this instanceof Writable,
`${this} does not inherit from Writable`
);
}

Object.setPrototypeOf(CustomWritable, Writable);
Object.setPrototypeOf(CustomWritable.prototype, Writable.prototype);

new CustomWritable();

assert.throws(CustomWritable,
common.expectsError({
code: 'ERR_ASSERTION',
message: /^inherits from Writable$/
}));
common.expectsError(
CustomWritable,
{
code: 'ERR_ASSERTION',
type: assert.AssertionError,
message: 'undefined does not inherit from CustomWritable'
}
);

0 comments on commit eb46609

Please sign in to comment.