diff --git a/test/parallel/test-buffer-slow.js b/test/parallel/test-buffer-slow.js index 8889d8d77de135..e41dd1dd0fd3a0 100644 --- a/test/parallel/test-buffer-slow.js +++ b/test/parallel/test-buffer-slow.js @@ -58,13 +58,13 @@ const bufferMaxSizeMsg = common.expectsError({ assert.throws(function() { SlowBuffer(Infinity); }, bufferMaxSizeMsg); -assert.throws(function() { +common.expectsError(function() { SlowBuffer(-1); -}, common.expectsError({ +}, { code: 'ERR_INVALID_OPT_VALUE', type: RangeError, message: 'The value "-1" is invalid for option "size"' -})); +}); assert.throws(function() { SlowBuffer(buffer.kMaxLength + 1); diff --git a/test/parallel/test-buffer-tostring-range.js b/test/parallel/test-buffer-tostring-range.js index 0fba12fabfdef5..f6ee846dd8ef34 100644 --- a/test/parallel/test-buffer-tostring-range.js +++ b/test/parallel/test-buffer-tostring-range.js @@ -84,17 +84,17 @@ assert.strictEqual(rangeBuffer.toString({ toString: function() { } }), 'abc'); // try toString() with 0 and null as the encoding -assert.throws(() => { +common.expectsError(() => { rangeBuffer.toString(0, 1, 2); -}, common.expectsError({ +}, { code: 'ERR_UNKNOWN_ENCODING', type: TypeError, message: 'Unknown encoding: 0' -})); -assert.throws(() => { +}); +common.expectsError(() => { rangeBuffer.toString(null, 1, 2); -}, common.expectsError({ +}, { code: 'ERR_UNKNOWN_ENCODING', type: TypeError, message: 'Unknown encoding: null' -})); +}); diff --git a/test/parallel/test-child-process-send-type-error.js b/test/parallel/test-child-process-send-type-error.js index 29dd45f6bdd7ee..9c3a502a49a257 100644 --- a/test/parallel/test-child-process-send-type-error.js +++ b/test/parallel/test-child-process-send-type-error.js @@ -5,9 +5,9 @@ const assert = require('assert'); const cp = require('child_process'); function fail(proc, args) { - assert.throws(() => { + common.expectsError(() => { proc.send.apply(proc, args); - }, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError })); + }, { code: 'ERR_INVALID_ARG_TYPE', type: TypeError }); } let target = process; diff --git a/test/parallel/test-child-process-spawnsync-kill-signal.js b/test/parallel/test-child-process-spawnsync-kill-signal.js index c9f601a0caff78..90222e04c97c9e 100644 --- a/test/parallel/test-child-process-spawnsync-kill-signal.js +++ b/test/parallel/test-child-process-spawnsync-kill-signal.js @@ -29,9 +29,9 @@ if (process.argv[2] === 'child') { } // Verify that an error is thrown for unknown signals. - assert.throws(() => { + common.expectsError(() => { spawn('SIG_NOT_A_REAL_SIGNAL'); - }, common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL', type: TypeError })); + }, { code: 'ERR_UNKNOWN_SIGNAL', type: TypeError }); // Verify that the default kill signal is SIGTERM. { diff --git a/test/parallel/test-child-process-stdio.js b/test/parallel/test-child-process-stdio.js index f1d18d437fd458..8624a13e1beace 100644 --- a/test/parallel/test-child-process-stdio.js +++ b/test/parallel/test-child-process-stdio.js @@ -40,6 +40,6 @@ options = { stdio: 'ignore' }; child = spawnSync('cat', [], options); assert.deepStrictEqual(options, { stdio: 'ignore' }); -assert.throws(() => { +common.expectsError(() => { common.spawnPwd({ stdio: ['pipe', 'pipe', 'pipe', 'ipc', 'ipc'] }); -}, common.expectsError({ code: 'ERR_IPC_ONE_PIPE', type: Error })); +}, { code: 'ERR_IPC_ONE_PIPE', type: Error }); diff --git a/test/parallel/test-child-process-validate-stdio.js b/test/parallel/test-child-process-validate-stdio.js index 129ca9822afcd5..4c4f137110b67e 100644 --- a/test/parallel/test-child-process-validate-stdio.js +++ b/test/parallel/test-child-process-validate-stdio.js @@ -26,8 +26,9 @@ assert.throws(() => _validateStdio(600), expectedError); // should throw if stdio has ipc and sync is true const stdio2 = ['ipc', 'ipc', 'ipc']; -assert.throws(() => _validateStdio(stdio2, true), - common.expectsError({ code: 'ERR_IPC_SYNC_FORK', type: Error })); +common.expectsError(() => _validateStdio(stdio2, true), + { code: 'ERR_IPC_SYNC_FORK', type: Error } +); { const stdio3 = [process.stdin, process.stdout, process.stderr]; diff --git a/test/parallel/test-common.js b/test/parallel/test-common.js index 7a73f93ae0f926..7a89b37660d5f6 100644 --- a/test/parallel/test-common.js +++ b/test/parallel/test-common.js @@ -45,12 +45,12 @@ assert.throws(function() { }, /^TypeError: Invalid minimum value: \/foo\/$/); // assert.fail() tests -assert.throws( +common.expectsError( () => { assert.fail('fhqwhgads'); }, - common.expectsError({ + { code: 'ERR_ASSERTION', message: /^fhqwhgads$/ - })); + }); const fnOnce = common.mustCall(() => {}); fnOnce(); diff --git a/test/parallel/test-console-instance.js b/test/parallel/test-console-instance.js index 20ac2ceb72a36c..9f31ebf3afcb58 100644 --- a/test/parallel/test-console-instance.js +++ b/test/parallel/test-console-instance.js @@ -37,13 +37,13 @@ assert.strictEqual('function', typeof Console); // make sure that the Console constructor throws // when not given a writable stream instance -assert.throws( +common.expectsError( () => { new Console(); }, - common.expectsError({ + { code: 'ERR_CONSOLE_WRITABLE_STREAM', type: TypeError, message: /stdout/ - }) + } ); // Console constructor should throw if stderr exists but is not writable diff --git a/test/parallel/test-dgram-bind.js b/test/parallel/test-dgram-bind.js index 4e293a8021c160..0b8447c3115da1 100644 --- a/test/parallel/test-dgram-bind.js +++ b/test/parallel/test-dgram-bind.js @@ -27,13 +27,13 @@ const dgram = require('dgram'); const socket = dgram.createSocket('udp4'); socket.on('listening', common.mustCall(() => { - assert.throws(() => { + common.expectsError(() => { socket.bind(); - }, common.expectsError({ + }, { code: 'ERR_SOCKET_ALREADY_BOUND', type: Error, message: /^Socket is already bound$/ - })); + }); socket.close(); })); diff --git a/test/parallel/test-dgram-create-socket-handle.js b/test/parallel/test-dgram-create-socket-handle.js index a593324de85418..57480f7d2cfaa6 100644 --- a/test/parallel/test-dgram-create-socket-handle.js +++ b/test/parallel/test-dgram-create-socket-handle.js @@ -6,12 +6,12 @@ const UDP = process.binding('udp_wrap').UDP; const _createSocketHandle = dgram._createSocketHandle; // Throws if an "existing fd" is passed in. -assert.throws(() => { +common.expectsError(() => { _createSocketHandle(common.localhostIPv4, 0, 'udp4', 42); -}, common.expectsError({ +}, { code: 'ERR_ASSERTION', message: /^false == true$/ -})); +}); { // Create a handle that is not bound.