Skip to content
Myr

command.executableSubcommand.inspect.test.js

This file

Path

tests/command.executableSubcommand.inspect.test.js

56 lines · 2.4 KiB · JavaScript

Last changed by

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

History of this file

Take it

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

lines 1–2why, one step back
1const childProcess = require('child_process');
2const path = require('path');

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 3why, one step back
3const util = require('util');

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

line 4why, one step back
4

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

lines 5–6why, one step back
5const execFileAsync = util.promisify(childProcess.execFile);
6

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

lines 7–11why, one step back
7// Test the special handling for --inspect to increment fixed debug port numbers.
8// If we reuse port we can get conflicts because port not released fast enough.910const inspectCommand = path.join(__dirname, './fixtures', 'inspect.js');11

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

lines 12–14why, one step back
12test('when execArgv empty then spawn execArgs empty', async() => {
13 const { stdout } = await execFileAsync('node', [inspectCommand, 'sub']);14 expect(stdout).toBe('[]\n');

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

lines 15–16why, one step back
15});
16

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

lines 17–19why, one step back
17test('when execArgv --harmony then spawn execArgs --harmony', async() => {
18 const { stdout } = await execFileAsync('node', ['--harmony', inspectCommand, 'sub']);19 expect(stdout).toBe("[ '--harmony' ]\n");

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

lines 20–22why, one step back
20});
2122// --inspect defaults to 127.0.0.1:9229, port should be incremented

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

lines 23–25why, one step back
23test('when execArgv --inspect then spawn execArgs using port 9230', async() => {
24 const { stdout } = await execFileAsync('node', ['--inspect', inspectCommand, 'sub']);25 expect(stdout).toBe("[ '--inspect=127.0.0.1:9230' ]\n");

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

lines 26–28why, one step back
26});
2728// custom port

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

lines 29–31why, one step back
29test('when execArgv --inspect=9240 then spawn execArgs using port 9241', async() => {
30 const { stdout } = await execFileAsync('node', ['--inspect=9240', inspectCommand, 'sub']);31 expect(stdout).toBe("[ '--inspect=127.0.0.1:9241' ]\n");

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

lines 32–34why, one step back
32});
3334// zero is special, random port

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

lines 35–37why, one step back
35test('when execArgv --inspect=0 then spawn execArgs --inspect=0', async() => {
36 const { stdout } = await execFileAsync('node', ['--inspect=0', inspectCommand, 'sub']);37 expect(stdout).toBe("[ '--inspect=0' ]\n");

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

lines 38–40why, one step back
38});
3940// ip address

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

lines 41–43why, one step back
41test('when execArgv --inspect=127.0.0.1:9250 then spawn execArgs --inspect=127.0.0.1:9251', async() => {
42 const { stdout } = await execFileAsync('node', ['--inspect=127.0.0.1:9250', inspectCommand, 'sub']);43 expect(stdout).toBe("[ '--inspect=127.0.0.1:9251' ]\n");

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

lines 44–46why, one step back
44});
4546// localhost

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

lines 47–49why, one step back
47test('when execArgv --inspect=localhost:9260 then spawn execArgs --inspect=localhost:9261', async() => {
48 const { stdout } = await execFileAsync('node', ['--inspect=localhost:9260', inspectCommand, 'sub']);49 expect(stdout).toBe("[ '--inspect=localhost:9261' ]\n");

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

lines 50–52why, one step back
50});
5152// --inspect-port, just test most likely format

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

lines 53–55why, one step back
53test('when execArgv --inspect-port=9270 then spawn execArgs --inspect-port=127.0.0.1:9271', async() => {
54 const { stdout } = await execFileAsync('node', ['--inspect-port=9270', inspectCommand, 'sub']);55 expect(stdout).toBe("[ '--inspect-port=127.0.0.1:9271' ]\n");

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

line 56why, one step back
56});