diff options
Diffstat (limited to 'deps/node-inspect/test/cli/launch.test.js')
-rw-r--r-- | deps/node-inspect/test/cli/launch.test.js | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/deps/node-inspect/test/cli/launch.test.js b/deps/node-inspect/test/cli/launch.test.js index 99c6ce0aa2..f7efc6eb3f 100644 --- a/deps/node-inspect/test/cli/launch.test.js +++ b/deps/node-inspect/test/cli/launch.test.js @@ -5,17 +5,38 @@ const { test } = require('tap'); const startCLI = require('./start-cli'); -test('examples/empty.js', (t) => { - const script = Path.join('examples', 'empty.js'); +test('custom port', (t) => { + const CUSTOM_PORT = '9230'; + const script = Path.join('examples', 'three-lines.js'); + + const cli = startCLI([`--port=${CUSTOM_PORT}`, script]); + + return cli.waitForInitialBreak() + .then(() => cli.waitForPrompt()) + .then(() => { + t.match(cli.output, 'debug>', 'prints a prompt'); + t.match( + cli.output, + new RegExp(`< Debugger listening on [^\n]*${CUSTOM_PORT}`), + 'forwards child output'); + }) + .then(() => cli.quit()) + .then((code) => { + t.equal(code, 0, 'exits with success'); + }); +}); + +test('examples/three-lines.js', (t) => { + const script = Path.join('examples', 'three-lines.js'); const cli = startCLI([script]); - return cli.waitFor(/break/) + return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => { t.match(cli.output, 'debug>', 'prints a prompt'); t.match( cli.output, - '< Debugger listening on port 9229', + /< Debugger listening on [^\n]*9229/, 'forwards child output'); }) .then(() => cli.command('["hello", "world"].join(" ")')) @@ -45,7 +66,7 @@ test('run after quit / restart', (t) => { throw error; } - return cli.waitFor(/break/) + return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => cli.stepCommand('n')) .then(() => { @@ -72,6 +93,7 @@ test('run after quit / restart', (t) => { t.match(cli.output, 'Use `run` to start the app again'); }) .then(() => cli.stepCommand('run')) + .then(() => cli.waitForInitialBreak()) .then(() => cli.waitForPrompt()) .then(() => { t.match( @@ -87,6 +109,7 @@ test('run after quit / restart', (t) => { 'steps to the 2nd line'); }) .then(() => cli.stepCommand('restart')) + .then(() => cli.waitForInitialBreak()) .then(() => { t.match( cli.output, @@ -100,6 +123,7 @@ test('run after quit / restart', (t) => { t.match(cli.output, 'Use `run` to start the app again'); }) .then(() => cli.stepCommand('run')) + .then(() => cli.waitForInitialBreak()) .then(() => cli.waitForPrompt()) .then(() => { t.match( |