node/test/parallel/test-debugger-low-level.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

35 lines
956 B
JavaScript

'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
const fixtures = require('../common/fixtures');
const startCLI = require('../common/debugger');
const assert = require('assert');
// Debugger agent direct access.
{
const cli = startCLI([fixtures.path('debugger/three-lines.js')]);
const scriptPattern = /^\* (\d+): \S+debugger(?:\/|\\)three-lines\.js/m;
async function testDebuggerLowLevel() {
try {
await cli.waitForInitialBreak();
await cli.waitForPrompt();
await cli.command('scripts');
const [, scriptId] = cli.output.match(scriptPattern);
await cli.command(
`Debugger.getScriptSource({ scriptId: '${scriptId}' })`
);
assert.match(
cli.output,
/scriptSource:[ \n]*'(?:\(function \(|let x = 1)/);
assert.match(
cli.output,
/let x = 1;/);
} finally {
await cli.quit();
}
}
testDebuggerLowLevel();
}