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 e6907f0

Browse filesBrowse files
juanarboltargos
authored andcommitted
test: improve test coverage in child_process
PR-URL: #26282 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 7bfc339 commit e6907f0
Copy full SHA for e6907f0

File tree

Expand file treeCollapse file tree

1 file changed

+16
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-4
lines changed
Open diff view settings
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
+16-4Lines changed: 16 additions & 4 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.