@@ -4,6 +4,7 @@ var path = require('path')
44var cp = require ( 'child_process' )
55var request = require ( 'supertest' )
66var rmrf = require ( 'rimraf' )
7+ var serverReady = require ( 'server-ready' )
78var pkg = require ( '../../package.json' )
89
910var PORT = 3100
@@ -44,7 +45,7 @@ describe('cli', function () {
4445
4546 beforeEach ( function ( done ) {
4647 child = cli ( [ dbFile ] )
47- setTimeout ( done , 1000 )
48+ serverReady ( PORT , done )
4849 } )
4950
5051 it ( 'should support JSON dbFile' , function ( done ) {
@@ -57,7 +58,7 @@ describe('cli', function () {
5758
5859 beforeEach ( function ( done ) {
5960 child = cli ( [ 'fixtures/seed.js' ] )
60- setTimeout ( done , 1000 )
61+ serverReady ( PORT , done )
6162 } )
6263
6364 it ( 'should support JS file' , function ( done ) {
@@ -84,7 +85,7 @@ describe('cli', function () {
8485
8586 beforeEach ( function ( done ) {
8687 child = cli ( [ dbFile , '-r' , routesFile , '-i' , '_id' ] )
87- setTimeout ( done , 1000 )
88+ serverReady ( PORT , done )
8889 } )
8990
9091 it ( 'should use routes.json and _id as the identifier' , function ( done ) {
@@ -97,7 +98,7 @@ describe('cli', function () {
9798
9899 beforeEach ( function ( done ) {
99100 child = cli ( [ dbFile , '-d' , 1000 ] )
100- setTimeout ( done , 1000 )
101+ serverReady ( PORT , done )
101102 } )
102103
103104 it ( 'should delay response' , function ( done ) {
@@ -117,7 +118,7 @@ describe('cli', function () {
117118
118119 beforeEach ( function ( done ) {
119120 child = cli ( [ '--watch' , dbFile , '-r' , routesFile ] )
120- setTimeout ( done , 1000 )
121+ serverReady ( PORT , done )
121122 } )
122123
123124 it ( 'should watch db file' , function ( done ) {
0 commit comments