node/test/parallel/test-debugger-auto-resume.mjs
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

34 lines
860 B
JavaScript

import { skipIfInspectorDisabled } from '../common/index.mjs';
skipIfInspectorDisabled();
import { path as _path } from '../common/fixtures.js';
import startCLI from '../common/debugger.js';
import { addLibraryPath } from '../common/shared-lib-util.js';
import { deepStrictEqual, strictEqual } from 'assert';
import { relative } from 'path';
addLibraryPath(process.env);
// Auto-resume on start if the environment variable is defined.
{
const scriptFullPath = _path('debugger', 'break.js');
const script = relative(process.cwd(), scriptFullPath);
const env = {
...process.env,
};
env.NODE_INSPECT_RESUME_ON_START = '1';
const cli = startCLI([script], [], { env });
await cli.waitForInitialBreak();
deepStrictEqual(cli.breakInfo, {
filename: script,
line: 10,
});
const code = await cli.quit();
strictEqual(code, 0);
}