Skip to content

Commit 697b5a7

Browse files
committed
Fix tests being run before REPL finishes exiting
Resolves issue as reported in issue comment #92 (comment)
1 parent bb9ef0f commit 697b5a7

File tree

1 file changed

+12
-22
lines changed
  • lib/node_modules/@stdlib/repl/test

1 file changed

+12
-22
lines changed

lib/node_modules/@stdlib/repl/test/test.js

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,12 @@ tape( 'the function starts a REPL environment', function test( t ) {
108108
return t.end();
109109
}
110110
t.ok( true, 'starts a REPL' );
111-
setTimeout( onTimeout, 0 );
112-
113-
function onTimeout() {
114-
// In Node v0.10, the REPLServer instance does not have a `close()` method...
115-
if ( server.close ) {
116-
server.close();
117-
} else {
118-
server.rli.close();
119-
}
120-
setTimeout( onEnd, 2500 );
121-
}
111+
server.rli.on( 'close', onClose );
112+
server.rli.write( '.exit\n' );
113+
}
114+
115+
function onClose() {
116+
setTimeout( onEnd, 1000 );
122117
}
123118

124119
function onEnd() {
@@ -135,17 +130,12 @@ tape( 'the function starts a REPL environment (options)', function test( t ) {
135130
return t.end();
136131
}
137132
t.ok( true, 'starts a REPL' );
138-
setTimeout( onTimeout, 0 );
139-
140-
function onTimeout() {
141-
// In Node v0.10, the REPLServer instance does not have a `close()` method...
142-
if ( server.close ) {
143-
server.close();
144-
} else {
145-
server.rli.close();
146-
}
147-
setTimeout( onEnd, 2500 );
148-
}
133+
server.rli.on( 'close', onClose );
134+
server.rli.write( '.exit\n' );
135+
}
136+
137+
function onClose() {
138+
setTimeout( onEnd, 1000 );
149139
}
150140

151141
function onEnd() {

0 commit comments

Comments
 (0)