node/test/parallel/test-repl-import-referrer.js
Dario Piotrowicz 53abd1a7e2
test: add missing newlines to repl .exit writes
some tests write `.exit` into a repl server without
including a newline character (`\n`), such commands
are therefore simply not executed at all, the changes
here add the missing newlines and as a side effect
remove no longer necessary `end` calls

PR-URL: https://github.com/nodejs/node/pull/58041
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
2025-04-28 20:19:07 +00:00

26 lines
729 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fixtures = require('../common/fixtures');
const args = ['--interactive'];
const opts = { cwd: fixtures.path('es-modules') };
const child = cp.spawn(process.execPath, args, opts);
let output = '';
child.stdout.setEncoding('utf8');
child.stdout.on('data', (data) => {
output += data;
});
child.on('exit', common.mustCall(() => {
const results = output.replace(/^> /mg, '').split('\n').slice(2);
assert.deepStrictEqual(
results,
['[Module: null prototype] { message: \'A message\' }', '']
);
}));
child.stdin.write('await import(\'./message.mjs\');\n');
child.stdin.write('.exit\n');