Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 28b2d8a

Browse filesBrowse files
mithunsasidharanMylesBorins
authored andcommitted
test: use common.expectsError in tests
PR-URL: #17484 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me>
1 parent d15cdc6 commit 28b2d8a
Copy full SHA for 28b2d8a
Expand file treeCollapse file tree

10 files changed

+30
-29
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-buffer-slow.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-buffer-slow.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ const bufferMaxSizeMsg = common.expectsError({
5858
assert.throws(function() {
5959
SlowBuffer(Infinity);
6060
}, bufferMaxSizeMsg);
61-
assert.throws(function() {
61+
common.expectsError(function() {
6262
SlowBuffer(-1);
63-
}, common.expectsError({
63+
}, {
6464
code: 'ERR_INVALID_OPT_VALUE',
6565
type: RangeError,
6666
message: 'The value "-1" is invalid for option "size"'
67-
}));
67+
});
6868

6969
assert.throws(function() {
7070
SlowBuffer(buffer.kMaxLength + 1);
Collapse file

‎test/parallel/test-buffer-tostring-range.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-buffer-tostring-range.js
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,17 @@ assert.strictEqual(rangeBuffer.toString({ toString: function() {
8484
} }), 'abc');
8585

8686
// try toString() with 0 and null as the encoding
87-
assert.throws(() => {
87+
common.expectsError(() => {
8888
rangeBuffer.toString(0, 1, 2);
89-
}, common.expectsError({
89+
}, {
9090
code: 'ERR_UNKNOWN_ENCODING',
9191
type: TypeError,
9292
message: 'Unknown encoding: 0'
93-
}));
94-
assert.throws(() => {
93+
});
94+
common.expectsError(() => {
9595
rangeBuffer.toString(null, 1, 2);
96-
}, common.expectsError({
96+
}, {
9797
code: 'ERR_UNKNOWN_ENCODING',
9898
type: TypeError,
9999
message: 'Unknown encoding: null'
100-
}));
100+
});
Collapse file

‎test/parallel/test-child-process-send-type-error.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-send-type-error.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const assert = require('assert');
55
const cp = require('child_process');
66

77
function fail(proc, args) {
8-
assert.throws(() => {
8+
common.expectsError(() => {
99
proc.send.apply(proc, args);
10-
}, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }));
10+
}, { code: 'ERR_INVALID_ARG_TYPE', type: TypeError });
1111
}
1212

1313
let target = process;
Collapse file

‎test/parallel/test-child-process-spawnsync-kill-signal.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-spawnsync-kill-signal.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ if (process.argv[2] === 'child') {
2929
}
3030

3131
// Verify that an error is thrown for unknown signals.
32-
assert.throws(() => {
32+
common.expectsError(() => {
3333
spawn('SIG_NOT_A_REAL_SIGNAL');
34-
}, common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL', type: TypeError }));
34+
}, { code: 'ERR_UNKNOWN_SIGNAL', type: TypeError });
3535

3636
// Verify that the default kill signal is SIGTERM.
3737
{
Collapse file

‎test/parallel/test-child-process-stdio.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-stdio.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ options = { stdio: 'ignore' };
4040
child = spawnSync('cat', [], options);
4141
assert.deepStrictEqual(options, { stdio: 'ignore' });
4242

43-
assert.throws(() => {
43+
common.expectsError(() => {
4444
common.spawnPwd({ stdio: ['pipe', 'pipe', 'pipe', 'ipc', 'ipc'] });
45-
}, common.expectsError({ code: 'ERR_IPC_ONE_PIPE', type: Error }));
45+
}, { code: 'ERR_IPC_ONE_PIPE', type: Error });
Collapse file

‎test/parallel/test-child-process-validate-stdio.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-validate-stdio.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ assert.throws(() => _validateStdio(600), expectedError);
2626

2727
// should throw if stdio has ipc and sync is true
2828
const stdio2 = ['ipc', 'ipc', 'ipc'];
29-
assert.throws(() => _validateStdio(stdio2, true),
30-
common.expectsError({ code: 'ERR_IPC_SYNC_FORK', type: Error }));
29+
common.expectsError(() => _validateStdio(stdio2, true),
30+
{ code: 'ERR_IPC_SYNC_FORK', type: Error }
31+
);
3132

3233
{
3334
const stdio3 = [process.stdin, process.stdout, process.stderr];
Collapse file

‎test/parallel/test-common.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-common.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ assert.throws(function() {
4545
}, /^TypeError: Invalid minimum value: \/foo\/$/);
4646

4747
// assert.fail() tests
48-
assert.throws(
48+
common.expectsError(
4949
() => { assert.fail('fhqwhgads'); },
50-
common.expectsError({
50+
{
5151
code: 'ERR_ASSERTION',
5252
message: /^fhqwhgads$/
53-
}));
53+
});
5454

5555
const fnOnce = common.mustCall(() => {});
5656
fnOnce();
Collapse file

‎test/parallel/test-console-instance.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-console-instance.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ assert.strictEqual('function', typeof Console);
3737

3838
// make sure that the Console constructor throws
3939
// when not given a writable stream instance
40-
assert.throws(
40+
common.expectsError(
4141
() => { new Console(); },
42-
common.expectsError({
42+
{
4343
code: 'ERR_CONSOLE_WRITABLE_STREAM',
4444
type: TypeError,
4545
message: /stdout/
46-
})
46+
}
4747
);
4848

4949
// Console constructor should throw if stderr exists but is not writable
Collapse file

‎test/parallel/test-dgram-bind.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-dgram-bind.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ const dgram = require('dgram');
2727
const socket = dgram.createSocket('udp4');
2828

2929
socket.on('listening', common.mustCall(() => {
30-
assert.throws(() => {
30+
common.expectsError(() => {
3131
socket.bind();
32-
}, common.expectsError({
32+
}, {
3333
code: 'ERR_SOCKET_ALREADY_BOUND',
3434
type: Error,
3535
message: /^Socket is already bound$/
36-
}));
36+
});
3737

3838
socket.close();
3939
}));
Collapse file

‎test/parallel/test-dgram-create-socket-handle.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-dgram-create-socket-handle.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ const UDP = process.binding('udp_wrap').UDP;
66
const _createSocketHandle = dgram._createSocketHandle;
77

88
// Throws if an "existing fd" is passed in.
9-
assert.throws(() => {
9+
common.expectsError(() => {
1010
_createSocketHandle(common.localhostIPv4, 0, 'udp4', 42);
11-
}, common.expectsError({
11+
}, {
1212
code: 'ERR_ASSERTION',
1313
message: /^false == true$/
14-
}));
14+
});
1515

1616
{
1717
// Create a handle that is not bound.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.