Skip to content

Commit 69404ec

Browse files
TrottMylesBorins
authored andcommitted
test: fix flaky test-force-repl
Increase time allowed for startup from 1 second to 5 seconds to avoid occasional flakiness. While at it, refactor a few minor things such as var->const and using common.mustCall(). Fixes: #8483 PR-URL: #8484 Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 88bb65d commit 69404ec

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

test/parallel/test-force-repl.js

+9-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
4-
var spawn = require('child_process').spawn;
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const spawn = require('child_process').spawn;
55

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

1312
cp.stdout.setEncoding('utf8');
1413

15-
cp.stdout.once('data', function(b) {
14+
cp.stdout.once('data', common.mustCall(function(b) {
1615
clearTimeout(timeoutId);
17-
assert.equal(b, '> ');
18-
gotToEnd = true;
16+
assert.strictEqual(b, '> ');
1917
cp.kill();
20-
});
21-
22-
process.on('exit', function() {
23-
assert(gotToEnd);
24-
});
18+
}));

0 commit comments

Comments
 (0)