Skip to content
Closed
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
Next Next commit
test: improve assertion fail messages
  • Loading branch information
refack committed Aug 19, 2017
commit 21b182062b89a27a55f8dcd87fe28355e8d92597
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 inherits from CustomWritable`
);
assert.ok(
this instanceof Writable,
`${this} does not inherits 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 inherits from CustomWritable'
}
);