diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js index 6afcbf1b03b8e1..feca44881192f6 100644 --- a/test/parallel/test-buffer-alloc.js +++ b/test/parallel/test-buffer-alloc.js @@ -967,12 +967,16 @@ common.expectsError( message: 'argument must be a buffer' }); -const regErrorMsg = - new RegExp('The first argument must be one of type string, Buffer, ' + - 'ArrayBuffer, Array, or Array-like Object\\.'); - -assert.throws(() => Buffer.from(), regErrorMsg); -assert.throws(() => Buffer.from(null), regErrorMsg); +assert.throws(() => Buffer.from(), { + name: 'TypeError [ERR_INVALID_ARG_TYPE]', + message: 'The first argument must be one of type string, Buffer, ' + + 'ArrayBuffer, Array, or Array-like Object. Received type undefined' +}); +assert.throws(() => Buffer.from(null), { + name: 'TypeError [ERR_INVALID_ARG_TYPE]', + message: 'The first argument must be one of type string, Buffer, ' + + 'ArrayBuffer, Array, or Array-like Object. Received type object' +}); // Test prototype getters don't throw assert.strictEqual(Buffer.prototype.parent, undefined); diff --git a/test/parallel/test-buffer-arraybuffer.js b/test/parallel/test-buffer-arraybuffer.js index 8d26f983f2b4dd..2a1ce141079279 100644 --- a/test/parallel/test-buffer-arraybuffer.js +++ b/test/parallel/test-buffer-arraybuffer.js @@ -40,7 +40,12 @@ assert.throws(function() { Object.setPrototypeOf(AB, ArrayBuffer); Object.setPrototypeOf(AB.prototype, ArrayBuffer.prototype); Buffer.from(new AB()); -}, TypeError); +}, { + code: 'ERR_INVALID_ARG_TYPE', + name: 'TypeError [ERR_INVALID_ARG_TYPE]', + message: 'The first argument must be one of type string, Buffer,' + + ' ArrayBuffer, Array, or Array-like Object. Received type object' +}); // Test the byteOffset and length arguments {