Files
node/test/sequential/test-debug-prompt.js
Matteo Collina 219dbd6c71 test: unflake debugger and REPL tests
Run the debugger function-formatting checks against an auto-resumed,
long-lived target so they do not depend on initial-break rendering.

Use a synchronous VM evaluator for the REPL handleError test. Submit the
throwing input separately and wait for clean REPL teardown.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/64718
Refs: https://github.com/nodejs/node/actions/runs/30080039199/job/89439279468?pr=64339
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-08-03 12:49:21 +00:00

47 lines
1.2 KiB
JavaScript

'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
const assert = require('assert');
const fixtures = require('../common/fixtures');
const spawn = require('child_process').spawn;
const proc = spawn(process.execPath, [
'inspect', fixtures.path('debugger', 'alive.js'),
]);
proc.stdout.setEncoding('utf8');
const TIMEOUT = common.platformTimeout(10_000);
let output = '';
let promptSeen = false;
(async () => {
await new Promise((resolve, reject) => {
const timer = setTimeout(() => {
proc.kill();
reject(new Error(`Timed out waiting for the debugger prompt; output: ${output}`));
}, TIMEOUT);
proc.stdout.on('data', (data) => {
output += data;
if (output.includes('debug> ') && !promptSeen) {
promptSeen = true;
proc.stdin.end('.exit\n');
}
});
proc.once('error', reject);
proc.once('close', common.mustCall((code, signal) => {
clearTimeout(timer);
if (!promptSeen) {
reject(new Error(
`Debugger exited before showing the prompt (code ${code}, signal ${signal}); ` +
`output: ${output}`));
return;
}
assert.strictEqual(code, 0);
resolve();
}));
});
})().then(common.mustCall());