0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-repl-inspector.js
James M Snell fa543c00cd
test: move common.ArrayStream to separate module
In a continuing effort to de-monolithize `require('../common')`,
move `common.ArrayStream` out to a separate module that is
imported only when it is needed.

PR-URL: https://github.com/nodejs/node/pull/22447
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-08-23 16:51:56 -07:00

36 lines
909 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' } }"));