• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4common.skipIfInspectorDisabled();
5
6const { NodeInstance } = require('../common/inspector-helper.js');
7const assert = require('assert');
8
9async function runTest() {
10  const script = 'require(\'inspector\').console.log(\'hello world\');';
11  const child = new NodeInstance('--inspect-brk=0', script, '');
12
13  let out = '';
14  child.on('stdout', (line) => out += line);
15
16  const session = await child.connectInspectorSession();
17
18  const commands = [
19    { 'method': 'Runtime.enable' },
20    { 'method': 'Runtime.runIfWaitingForDebugger' },
21  ];
22
23  session.send(commands);
24
25  const msg = await session.waitForNotification('Runtime.consoleAPICalled');
26
27  assert.strictEqual(msg.params.type, 'log');
28  assert.deepStrictEqual(msg.params.args, [{
29    type: 'string',
30    value: 'hello world'
31  }]);
32  assert.strictEqual(out, '');
33
34  session.disconnect();
35}
36
37runTest().then(common.mustCall());
38