node/test/parallel/test-repl-paste-big-data.js
Dario Piotrowicz 9ac571d0d5
test: add new startNewREPLSever testing utility
PR-URL: https://github.com/nodejs/node/pull/59964
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
2025-09-30 15:20:02 +02:00

19 lines
567 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const { startNewREPLServer } = require('../common/repl');
// Pasting big input should not cause the process to have a huge CPU usage.
const cpuUsage = process.cpuUsage();
const { replServer } = startNewREPLServer({}, { disableDomainErrorAssert: true });
replServer.input.emit('data', 'a'.repeat(2e4) + '\n');
replServer.input.emit('data', '.exit\n');
replServer.once('exit', common.mustCall(() => {
const diff = process.cpuUsage(cpuUsage);
assert.ok(diff.user < 1e6);
}));