Skip to content

Commit

Permalink
Fix tests being run before REPL finishes exiting
Browse files Browse the repository at this point in the history
Resolves issue as reported in issue comment

#92 (comment)
  • Loading branch information
kgryte committed Jun 8, 2017
1 parent bb9ef0f commit 697b5a7
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions lib/node_modules/@stdlib/repl/test/test.js
Expand Up @@ -108,17 +108,12 @@ tape( 'the function starts a REPL environment', function test( t ) {
return t.end();
}
t.ok( true, 'starts a REPL' );
setTimeout( onTimeout, 0 );

function onTimeout() {
// In Node v0.10, the REPLServer instance does not have a `close()` method...
if ( server.close ) {
server.close();
} else {
server.rli.close();
}
setTimeout( onEnd, 2500 );
}
server.rli.on( 'close', onClose );
server.rli.write( '.exit\n' );
}

function onClose() {
setTimeout( onEnd, 1000 );
}

function onEnd() {
Expand All @@ -135,17 +130,12 @@ tape( 'the function starts a REPL environment (options)', function test( t ) {
return t.end();
}
t.ok( true, 'starts a REPL' );
setTimeout( onTimeout, 0 );

function onTimeout() {
// In Node v0.10, the REPLServer instance does not have a `close()` method...
if ( server.close ) {
server.close();
} else {
server.rli.close();
}
setTimeout( onEnd, 2500 );
}
server.rli.on( 'close', onClose );
server.rli.write( '.exit\n' );
}

function onClose() {
setTimeout( onEnd, 1000 );
}

function onEnd() {
Expand Down

0 comments on commit 697b5a7

Please sign in to comment.