@@ -4,6 +4,7 @@ var path = require('path')
4
4
var cp = require ( 'child_process' )
5
5
var request = require ( 'supertest' )
6
6
var rmrf = require ( 'rimraf' )
7
+ var serverReady = require ( 'server-ready' )
7
8
var pkg = require ( '../../package.json' )
8
9
9
10
var PORT = 3100
@@ -44,7 +45,7 @@ describe('cli', function () {
44
45
45
46
beforeEach ( function ( done ) {
46
47
child = cli ( [ dbFile ] )
47
- setTimeout ( done , 1000 )
48
+ serverReady ( PORT , done )
48
49
} )
49
50
50
51
it ( 'should support JSON dbFile' , function ( done ) {
@@ -57,7 +58,7 @@ describe('cli', function () {
57
58
58
59
beforeEach ( function ( done ) {
59
60
child = cli ( [ 'fixtures/seed.js' ] )
60
- setTimeout ( done , 1000 )
61
+ serverReady ( PORT , done )
61
62
} )
62
63
63
64
it ( 'should support JS file' , function ( done ) {
@@ -84,7 +85,7 @@ describe('cli', function () {
84
85
85
86
beforeEach ( function ( done ) {
86
87
child = cli ( [ dbFile , '-r' , routesFile , '-i' , '_id' ] )
87
- setTimeout ( done , 1000 )
88
+ serverReady ( PORT , done )
88
89
} )
89
90
90
91
it ( 'should use routes.json and _id as the identifier' , function ( done ) {
@@ -97,7 +98,7 @@ describe('cli', function () {
97
98
98
99
beforeEach ( function ( done ) {
99
100
child = cli ( [ dbFile , '-d' , 1000 ] )
100
- setTimeout ( done , 1000 )
101
+ serverReady ( PORT , done )
101
102
} )
102
103
103
104
it ( 'should delay response' , function ( done ) {
@@ -117,7 +118,7 @@ describe('cli', function () {
117
118
118
119
beforeEach ( function ( done ) {
119
120
child = cli ( [ '--watch' , dbFile , '-r' , routesFile ] )
120
- setTimeout ( done , 1000 )
121
+ serverReady ( PORT , done )
121
122
} )
122
123
123
124
it ( 'should watch db file' , function ( done ) {
0 commit comments