node/test/parallel/test-repl-inspector.js
Rich Trott 330f25ef82 test: prepare for consistent comma-dangle lint rule
Make changes so that tests will pass when the comma-dangle settings
applied to the rest of the code base are also applied to tests.

PR-URL: https://github.com/nodejs/node/pull/37930
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is>
2021-04-01 23:14:29 -07:00

36 lines
910 B
JavaScript

'use strict';
const common = require('../common');
const ArrayStream = require('../common/arraystream');
const assert = require('assert');
const repl = require('repl');
common.skipIfInspectorDisabled();
// This test verifies that the V8 inspector API is usable in the REPL.
const putIn = new ArrayStream();
let output = '';
putIn.write = function(data) {
output += data;
};
const testMe = repl.start('', putIn);
putIn.run(['const myVariable = 42']);
testMe.complete('myVar', common.mustCall((error, data) => {
assert.deepStrictEqual(data, [['myVariable'], 'myVar']);
}));
putIn.run([
'const inspector = require("inspector")',
'const session = new inspector.Session()',
'session.connect()',
'session.post("Runtime.evaluate", { expression: "1 + 1" }, console.log)',
'session.disconnect()',
]);
assert(output.includes(
"null { result: { type: 'number', value: 2, description: '2' } }"));