node/test/parallel/test-repl-save-load-load-non-existent.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
641 B
JavaScript

'use strict';
const common = require('../common');
const { startNewREPLServer } = require('../common/repl');
const assert = require('node:assert');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
// Tests that an appropriate error is displayed if the user tries to load a non existent file
const { replServer, input, output } = startNewREPLServer({ terminal: false });
const filePath = tmpdir.resolve('file.does.not.exist');
output.write = common.mustCall(function(data) {
assert.strictEqual(data, `Failed to load: ${filePath}\n`);
output.write = () => {};
});
input.run([`.load ${filePath}`]);
replServer.close();