node/test/sequential/test-debugger-invalid-args.js
Dario Piotrowicz 29626f8fb8
test: update startCLI to set --port=0 by default
update the `startCLI` debugging testing utility to set by default
the port to use to `0` (i.e. a random port)

PR-URL: https://github.com/nodejs/node/pull/59042
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2025-07-20 17:37:28 +00:00

27 lines
757 B
JavaScript

'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
const startCLI = require('../common/debugger');
const assert = require('assert');
// Launch CLI w/o args.
(async () => {
const cli = startCLI([], [], {}, { randomPort: false });
const code = await cli.quit();
assert.strictEqual(code, 9);
assert.match(cli.output, /^Usage:/, 'Prints usage info');
})().then(common.mustCall());
// Launch w/ invalid host:port.
(async () => {
const cli = startCLI([`localhost:${common.PORT}`], [], {}, { randomPort: false });
const code = await cli.quit();
assert.match(
cli.output,
/failed to connect/,
'Tells the user that the connection failed');
assert.strictEqual(code, 1);
})().then(common.mustCall());