• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const ArrayStream = require('../common/arraystream');
5const assert = require('assert');
6const repl = require('repl');
7
8common.skipIfInspectorDisabled();
9
10// This test verifies that the V8 inspector API is usable in the REPL.
11
12const putIn = new ArrayStream();
13let output = '';
14putIn.write = function(data) {
15  output += data;
16};
17
18const testMe = repl.start('', putIn);
19
20putIn.run(['const myVariable = 42']);
21
22testMe.complete('myVar', common.mustCall((error, data) => {
23  assert.deepStrictEqual(data, [['myVariable'], 'myVar']);
24}));
25
26putIn.run([
27  'const inspector = require("inspector")',
28  'const session = new inspector.Session()',
29  'session.connect()',
30  'session.post("Runtime.evaluate", { expression: "1 + 1" }, console.log)',
31  'session.disconnect()',
32]);
33
34assert(output.includes(
35  "null { result: { type: 'number', value: 2, description: '2' } }"));
36