mirror of
https://github.com/typicode/json-server.git
synced 2025-07-30 21:54:11 +08:00
Use server-ready to make CLI tests slightly faster
This commit is contained in:
@ -29,6 +29,7 @@
|
|||||||
"husky": "^0.6.1",
|
"husky": "^0.6.1",
|
||||||
"mocha": "^2.2.4",
|
"mocha": "^2.2.4",
|
||||||
"rimraf": "^2.4.1",
|
"rimraf": "^2.4.1",
|
||||||
|
"server-ready": "^0.2.0",
|
||||||
"standard": "^3.8.0",
|
"standard": "^3.8.0",
|
||||||
"supertest": "~0.8.1"
|
"supertest": "~0.8.1"
|
||||||
},
|
},
|
||||||
|
@ -4,6 +4,7 @@ var path = require('path')
|
|||||||
var cp = require('child_process')
|
var cp = require('child_process')
|
||||||
var request = require('supertest')
|
var request = require('supertest')
|
||||||
var rmrf = require('rimraf')
|
var rmrf = require('rimraf')
|
||||||
|
var serverReady = require('server-ready')
|
||||||
var pkg = require('../../package.json')
|
var pkg = require('../../package.json')
|
||||||
|
|
||||||
var PORT = 3100
|
var PORT = 3100
|
||||||
@ -44,7 +45,7 @@ describe('cli', function () {
|
|||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
child = cli([dbFile])
|
child = cli([dbFile])
|
||||||
setTimeout(done, 1000)
|
serverReady(PORT, done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should support JSON dbFile', function (done) {
|
it('should support JSON dbFile', function (done) {
|
||||||
@ -57,7 +58,7 @@ describe('cli', function () {
|
|||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
child = cli(['fixtures/seed.js'])
|
child = cli(['fixtures/seed.js'])
|
||||||
setTimeout(done, 1000)
|
serverReady(PORT, done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should support JS file', function (done) {
|
it('should support JS file', function (done) {
|
||||||
@ -84,7 +85,7 @@ describe('cli', function () {
|
|||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
child = cli([dbFile, '-r', routesFile, '-i', '_id'])
|
child = cli([dbFile, '-r', routesFile, '-i', '_id'])
|
||||||
setTimeout(done, 1000)
|
serverReady(PORT, done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should use routes.json and _id as the identifier', function (done) {
|
it('should use routes.json and _id as the identifier', function (done) {
|
||||||
@ -97,7 +98,7 @@ describe('cli', function () {
|
|||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
child = cli([dbFile, '-d', 1000])
|
child = cli([dbFile, '-d', 1000])
|
||||||
setTimeout(done, 1000)
|
serverReady(PORT, done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should delay response', function (done) {
|
it('should delay response', function (done) {
|
||||||
@ -117,7 +118,7 @@ describe('cli', function () {
|
|||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
child = cli(['--watch', dbFile, '-r', routesFile])
|
child = cli(['--watch', dbFile, '-r', routesFile])
|
||||||
setTimeout(done, 1000)
|
serverReady(PORT, done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should watch db file', function (done) {
|
it('should watch db file', function (done) {
|
||||||
|
Reference in New Issue
Block a user