From 42e06e114222dbb5061e65c107914905ae407295 Mon Sep 17 00:00:00 2001 From: Chengzhong Wu Date: Mon, 21 Oct 2024 13:52:36 +0100 Subject: [PATCH] test: add repl preview timeout test PR-URL: https://github.com/nodejs/node/pull/55484 Refs: https://github.com/v8/v8/commit/f915fa4c9f4162dd9258535eee03b1b0484bf38e Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca --- test/parallel/test-repl-preview-timeout.js | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/parallel/test-repl-preview-timeout.js diff --git a/test/parallel/test-repl-preview-timeout.js b/test/parallel/test-repl-preview-timeout.js new file mode 100644 index 00000000000000..df6a8cf2b1cba7 --- /dev/null +++ b/test/parallel/test-repl-preview-timeout.js @@ -0,0 +1,27 @@ +'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);