0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-repl-preview-timeout.js
Chengzhong Wu 7b5d660bb1 test: add repl preview timeout test
PR-URL: https://github.com/nodejs/node/pull/55484
Refs: f915fa4c9f
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2024-10-23 13:11:07 +00:00

28 lines
658 B
JavaScript

'use strict';
const common = require('../common');
const ArrayStream = require('../common/arraystream');
const assert = require('assert');
const repl = require('repl');
common.skipIfInspectorDisabled();
const inputStream = new ArrayStream();
const outputStream = new ArrayStream();
repl.start({
input: inputStream,
output: outputStream,
useGlobal: false,
terminal: true,
useColors: true
});
let output = '';
outputStream.write = (chunk) => output += chunk;
// Input without '\n' triggering actual run.
const input = 'while (true) {}';
inputStream.emit('data', input);
// No preview available when timed out.
assert.strictEqual(output, input);