0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-inspector-wait.mjs
Kohei Ueno c0ae3b2373
inspector: introduce the --inspect-wait flag
PR-URL: https://github.com/nodejs/node/pull/52734
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2024-05-11 18:48:30 +00:00

29 lines
991 B
JavaScript

import * as common from '../common/index.mjs';
common.skipIfInspectorDisabled();
import assert from 'node:assert';
import { NodeInstance } from '../common/inspector-helper.js';
async function runTests() {
const child = new NodeInstance(['--inspect-wait=0'], 'console.log(0);');
const session = await child.connectInspectorSession();
await session.send({ method: 'NodeRuntime.enable' });
await session.waitForNotification('NodeRuntime.waitingForDebugger');
// The execution should be paused until the debugger is attached
while (await child.nextStderrString() !== 'Debugger attached.');
await session.send({ 'method': 'Runtime.runIfWaitingForDebugger' });
// Wait for the execution to finish
while (await child.nextStderrString() !== 'Waiting for the debugger to disconnect...');
await session.send({ method: 'NodeRuntime.disable' });
session.disconnect();
assert.strictEqual((await child.expectShutdown()).exitCode, 0);
}
runTests().then(common.mustCall());