Skip to content

Commit e6907f0

Browse files
juanarboltargos
authored andcommitted
test: improve test coverage in child_process
PR-URL: #26282 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 7bfc339 commit e6907f0

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

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

+16-4
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ const common = require('../common');
55
const assert = require('assert');
66
const getValidStdio = require('internal/child_process').getValidStdio;
77

8-
const expectedError =
9-
common.expectsError({ code: 'ERR_INVALID_OPT_VALUE', type: TypeError }, 2);
8+
const expectedError = { code: 'ERR_INVALID_OPT_VALUE', type: TypeError };
109

1110
// Should throw if string and not ignore, pipe, or inherit
12-
assert.throws(() => getValidStdio('foo'), expectedError);
11+
common.expectsError(() => getValidStdio('foo'), expectedError);
1312

1413
// Should throw if not a string or array
15-
assert.throws(() => getValidStdio(600), expectedError);
14+
common.expectsError(() => getValidStdio(600), expectedError);
1615

1716
// Should populate stdio with undefined if len < 3
1817
{
@@ -30,6 +29,19 @@ common.expectsError(() => getValidStdio(stdio2, true),
3029
{ code: 'ERR_IPC_SYNC_FORK', type: Error }
3130
);
3231

32+
// Should throw if stdio is not a valid input
33+
{
34+
const stdio = ['foo'];
35+
common.expectsError(() => getValidStdio(stdio, false),
36+
{ code: 'ERR_INVALID_SYNC_FORK_INPUT', type: TypeError }
37+
);
38+
}
39+
40+
// Should throw if stdio is not a valid option
41+
{
42+
const stdio = [{ foo: 'bar' }];
43+
common.expectsError(() => getValidStdio(stdio), expectedError);
44+
}
3345

3446
if (common.isMainThread) {
3547
const stdio3 = [process.stdin, process.stdout, process.stderr];

0 commit comments

Comments
 (0)