Skip to content

Commit eb46609

Browse files
refackMylesBorins
authored andcommitted
test: improve assertion fail messages
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]>
1 parent 57c7eae commit eb46609

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

test/parallel/test-stream-inheritance.js

+16-7
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,26 @@ assert.ok(!(undefined instanceof Writable));
3333

3434
// Simple inheritance check for `Writable` works fine in a subclass constructor.
3535
function CustomWritable() {
36-
assert.ok(this instanceof Writable, 'inherits from Writable');
37-
assert.ok(this instanceof CustomWritable, 'inherits from CustomWritable');
36+
assert.ok(
37+
this instanceof CustomWritable,
38+
`${this} does not inherit from CustomWritable`
39+
);
40+
assert.ok(
41+
this instanceof Writable,
42+
`${this} does not inherit from Writable`
43+
);
3844
}
3945

4046
Object.setPrototypeOf(CustomWritable, Writable);
4147
Object.setPrototypeOf(CustomWritable.prototype, Writable.prototype);
4248

4349
new CustomWritable();
4450

45-
assert.throws(CustomWritable,
46-
common.expectsError({
47-
code: 'ERR_ASSERTION',
48-
message: /^inherits from Writable$/
49-
}));
51+
common.expectsError(
52+
CustomWritable,
53+
{
54+
code: 'ERR_ASSERTION',
55+
type: assert.AssertionError,
56+
message: 'undefined does not inherit from CustomWritable'
57+
}
58+
);

0 commit comments

Comments
 (0)