Skip to content
Myr

command.executableSubcommand.inspect.test.js

This file

Path

tests/command.executableSubcommand.inspect.test.js

69 lines · 2.6 KiB · JavaScript

Last changed by

Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4

History of this file

Take it

Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4

lines 1–69why, one step back
1const childProcess = require('child_process');
2const path = require('path');34// Test the special handling for --inspect to increment fixed debug port numbers.5// If we reuse port we can get conflicts because port not released fast enough.67const inspectCommand = path.join(__dirname, './fixtures', 'inspect.js');89test('when execArgv empty then spawn execArgs empty', (done) => {10 childProcess.execFile('node', [inspectCommand, 'sub'], function(_error, stdout, stderr) {11 expect(stdout).toBe('[]\n');12 done();13 });14});1516test('when execArgv --harmony then spawn execArgs --harmony', (done) => {17 childProcess.execFile('node', ['--harmony', inspectCommand, 'sub'], function(_error, stdout, stderr) {18 expect(stdout).toBe("[ '--harmony' ]\n");19 done();20 });21});2223// --inspect defaults to 127.0.0.1:9229, port should be incremented24test('when execArgv --inspect then spawn execArgs using port 9230', (done) => {25 childProcess.execFile('node', ['--inspect', inspectCommand, 'sub'], function(_error, stdout, stderr) {26 expect(stdout).toBe("[ '--inspect=127.0.0.1:9230' ]\n");27 done();28 });29});3031// custom port32test('when execArgv --inspect=9240 then spawn execArgs using port 9241', (done) => {33 childProcess.execFile('node', ['--inspect=9240', inspectCommand, 'sub'], function(_error, stdout, stderr) {34 expect(stdout).toBe("[ '--inspect=127.0.0.1:9241' ]\n");35 done();36 });37});3839// zero is special, random port40test('when execArgv --inspect=0 then spawn execArgs --inspect=0', (done) => {41 childProcess.execFile('node', ['--inspect=0', inspectCommand, 'sub'], function(_error, stdout, stderr) {42 expect(stdout).toBe("[ '--inspect=0' ]\n");43 done();44 });45});4647// ip address48test('when execArgv --inspect=127.0.0.1:9250 then spawn execArgs --inspect=127.0.0.1:9251', (done) => {49 childProcess.execFile('node', ['--inspect=127.0.0.1:9250', inspectCommand, 'sub'], function(_error, stdout, stderr) {50 expect(stdout).toBe("[ '--inspect=127.0.0.1:9251' ]\n");51 done();52 });53});5455// localhost56test('when execArgv --inspect=localhost:9260 then spawn execArgs --inspect=localhost:9261', (done) => {57 childProcess.execFile('node', ['--inspect=localhost:9260', inspectCommand, 'sub'], function(_error, stdout, stderr) {58 expect(stdout).toBe("[ '--inspect=localhost:9261' ]\n");59 done();60 });61});6263// --inspect-port, just test most likely format64test('when execArgv --inspect-port=9270 then spawn execArgs --inspect-port=127.0.0.1:9271', (done) => {65 childProcess.execFile('node', ['--inspect-port=9270', inspectCommand, 'sub'], function(_error, stdout, stderr) {66 expect(stdout).toBe("[ '--inspect-port=127.0.0.1:9271' ]\n");67 done();68 });69});