summaryrefslogtreecommitdiff
path: root/test/parallel/test-inspector-inspect-brk-node.js
blob: 0f4795ed7b87e44fbfd3d2fb883233e9e887b685 (plain)
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
'use strict';
const common = require('../common');

// Regression test for https://github.com/nodejs/node/issues/32648

common.skipIfInspectorDisabled();

const { NodeInstance } = require('../common/inspector-helper.js');

async function runTest() {
  const child = new NodeInstance(['--inspect-brk-node=0', '-p', '42']);
  const session = await child.connectInspectorSession();
  await session.send({ method: 'Runtime.enable' });
  await session.send({ method: 'Debugger.enable' });
  await session.send({ method: 'Runtime.runIfWaitingForDebugger' });
  await session.waitForNotification((notification) => {
    // The main assertion here is that we do hit the loader script first.
    return notification.method === 'Debugger.scriptParsed' &&
           notification.params.url === 'node:internal/bootstrap/loaders';
  });

  await session.waitForNotification('Debugger.paused');
  await session.send({ method: 'Debugger.resume' });
  await session.waitForNotification('Debugger.paused');
  await session.runToCompletion();
}

runTest().then(common.mustCall());