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 <gibfahn@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
refack authored and MylesBorins committed Sep 20, 2017
1 parent 7546eef commit 168f73c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/parallel/test-stream-inheritance.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@ 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, /AssertionError: inherits from Writable/);
assert.throws(CustomWritable, /AssertionError: undefined does not inherit from CustomWritable/);

0 comments on commit 168f73c

Please sign in to comment.