Skip to content

Commit 2ea2378

Browse files
author
chiaki-yokoo
committed
test: improve child_process test coverage
1 parent 595df9f commit 2ea2378

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
const assert = require('assert');
5+
const fork = require('child_process').fork;
6+
7+
const childScript = `${common.fixturesDir}/child-process-spawn-node`;
8+
const payload = {hello: 'world'};
9+
const stringOpts = {stdio: 'ignore'};
10+
11+
const child = fork(childScript, stringOpts);
12+
13+
child.on('message', (message) => {
14+
assert.deepStrictEqual(message, {foo: 'bar'});
15+
});
16+
17+
child.send(payload);
18+
19+
child.on('exit', common.mustCall((code) => assert.strictEqual(code, 0)));

test/parallel/test-child-process-spawn-typeerror.js

+3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ assert.throws(function() {
6767

6868
// Argument types for combinatorics
6969
const a = [];
70+
const attr = ['foo'];
7071
const o = {};
7172
const c = function c() {};
7273
const s = 'string';
@@ -153,6 +154,8 @@ assert.throws(function() { execFile(cmd, u, o, s); }, TypeError);
153154
assert.throws(function() { execFile(cmd, n, o, s); }, TypeError);
154155
assert.doesNotThrow(function() { execFile(cmd, c, s); });
155156

157+
// Check arguments array is not empty for execFile
158+
assert.doesNotThrow(function() { execFile(cmd, attr, o, c); });
156159

157160
// verify that fork has same argument parsing behaviour as spawn
158161
//

0 commit comments

Comments
 (0)