diff options
Diffstat (limited to 'test/parallel/test-child-process-constructor.js')
-rw-r--r-- | test/parallel/test-child-process-constructor.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/test/parallel/test-child-process-constructor.js b/test/parallel/test-child-process-constructor.js index c495f1895d..8e62f5cc23 100644 --- a/test/parallel/test-child-process-constructor.js +++ b/test/parallel/test-child-process-constructor.js @@ -8,44 +8,48 @@ assert.strictEqual(typeof ChildProcess, 'function'); { // Verify that invalid options to spawn() throw. const child = new ChildProcess(); + const re = /^TypeError: "options" must be an object$/; [undefined, null, 'foo', 0, 1, NaN, true, false].forEach((options) => { assert.throws(() => { child.spawn(options); - }, /^TypeError: "options" must be an object$/); + }, re); }); } { // Verify that spawn throws if file is not a string. const child = new ChildProcess(); + const re = /^TypeError: "file" must be a string$/; [undefined, null, 0, 1, NaN, true, false, {}].forEach((file) => { assert.throws(() => { child.spawn({ file }); - }, /^TypeError: "file" must be a string$/); + }, re); }); } { // Verify that spawn throws if envPairs is not an array or undefined. const child = new ChildProcess(); + const re = /^TypeError: "envPairs" must be an array$/; [null, 0, 1, NaN, true, false, {}, 'foo'].forEach((envPairs) => { assert.throws(() => { child.spawn({ envPairs, stdio: ['ignore', 'ignore', 'ignore', 'ipc'] }); - }, /^TypeError: "envPairs" must be an array$/); + }, re); }); } { // Verify that spawn throws if args is not an array or undefined. const child = new ChildProcess(); + const re = /^TypeError: "args" must be an array$/; [null, 0, 1, NaN, true, false, {}, 'foo'].forEach((args) => { assert.throws(() => { child.spawn({ file: 'foo', args }); - }, /^TypeError: "args" must be an array$/); + }, re); }); } |