Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions test/parallel/test-force-repl.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
const common = require('../common');
const assert = require('assert');
const spawn = require('child_process').spawn;

// spawn a node child process in "interactive" mode (force the repl)
var cp = spawn(process.execPath, ['-i']);
var gotToEnd = false;
const cp = spawn(process.execPath, ['-i']);
var timeoutId = setTimeout(function() {
throw new Error('timeout!');
}, common.platformTimeout(1000)); // give node + the repl 1 second to boot up
}, common.platformTimeout(5000)); // give node + the repl 5 seconds to start

cp.stdout.setEncoding('utf8');

cp.stdout.once('data', function(b) {
cp.stdout.once('dasta', common.mustCall(function(b) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dasta?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha! I added that to make sure the test fails if the callback never fired but then checked it in that way by accident.

clearTimeout(timeoutId);
assert.equal(b, '> ');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you’re refactoring this anyway you might as well use strictEqual here :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you’re refactoring this anyway you might as well use strictEqual here :)

Hey, shame on me. Yeah, I'll change equal() -> strictEqual().

gotToEnd = true;
cp.kill();
});

process.on('exit', function() {
assert(gotToEnd);
});
}));