test: improve assertion fail messages · nodejs/node@168f73c

Original file line numberDiff line numberDiff line change

@@ -33,13 +33,19 @@ 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, /AssertionError: inherits from Writable/);

51+

assert.throws(CustomWritable, /AssertionError: undefined does not inherit from CustomWritable/);