forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-inspector-wait.mjs
More file actions
28 lines (19 loc) · 991 Bytes
/
test-inspector-wait.mjs
File metadata and controls
28 lines (19 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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());