Skip to content

Commit ff336e5

Browse files
avoid setTimeout in test-repl-import-referrer.js
1 parent a104b57 commit ff336e5

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

test/parallel/test-repl-import-referrer.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,24 @@ const args = ['--interactive'];
88
const opts = { cwd: fixtures.path('es-modules') };
99
const child = cp.spawn(process.execPath, args, opts);
1010

11-
let output = '';
11+
const outputs = [];
1212
child.stdout.setEncoding('utf8');
1313
child.stdout.on('data', (data) => {
14-
output += data;
14+
outputs.push(data);
15+
if (outputs.length === 3) {
16+
// All the expected outputs have been received
17+
// so we can close the child process's stdin
18+
child.stdin.end();
19+
}
1520
});
1621

1722
child.on('exit', common.mustCall(() => {
18-
const results = output.replace(/^> /mg, '').split('\n').slice(2);
19-
assert.deepStrictEqual(
23+
const results = outputs[2].split('\n')[0];
24+
assert.strictEqual(
2025
results,
21-
['[Module: null prototype] { message: \'A message\' }', '']
26+
'[Module: null prototype] { message: \'A message\' }'
2227
);
2328
}));
2429

2530
child.stdin.write('await import(\'./message.mjs\');\n');
2631
child.stdin.write('.exit');
27-
setTimeout(() => {
28-
child.stdin.end();
29-
}, common.platformTimeout(300));

0 commit comments

Comments
 (0)