node/test/parallel/test-repl-empty.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

24 lines
637 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const { startNewREPLServer } = require('../common/repl');
let evalCalledWithExpectedArgs = false;
const { replServer } = startNewREPLServer({
eval: common.mustCall((cmd, context) => {
// Assertions here will not cause the test to exit with an error code
// so set a boolean that is checked later instead.
evalCalledWithExpectedArgs = (cmd === '\n');
})
});
try {
// Empty strings should be sent to the repl's eval function
replServer.write('\n');
} finally {
replServer.write('.exit\n');
}
assert(evalCalledWithExpectedArgs);