Skip to content

Commit a35f2c7

Browse files
committed
tests: close down http servers during testing
1 parent b5eb7b2 commit a35f2c7

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
},
4141
"scripts": {
4242
"lint": "eslint --plugin markdown --ext js,md .",
43-
"test": "mocha --check-leaks --reporter spec --bail",
43+
"test": "mocha --check-leaks --reporter spec --bail --no-exit",
4444
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --check-leaks --reporter dot",
45-
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --check-leaks --reporter spec"
45+
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --check-leaks --reporter spec --no-exit"
4646
}
4747
}

test/compression.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ describe('compression()', function () {
205205
client = res
206206
assert.strictEqual(res.headers['content-encoding'], 'gzip')
207207
res.pause()
208-
res.on('end', cb)
208+
res.on('end', function () {
209+
server.close(cb)
210+
})
209211
pressure()
210212
})
211213
.end()
@@ -258,7 +260,9 @@ describe('compression()', function () {
258260
client = res
259261
shouldNotHaveHeader('Content-Encoding')(res)
260262
res.pause()
261-
res.on('end', cb)
263+
res.on('end', function () {
264+
server.close(cb)
265+
})
262266
pressure()
263267
})
264268
.end()
@@ -594,7 +598,10 @@ describe('compression()', function () {
594598
.get('/')
595599
.set('Accept-Encoding', 'gzip')
596600
.request()
597-
.on('response', unchunk('gzip', onchunk, done))
601+
.on('response', unchunk('gzip', onchunk, function (err) {
602+
if (err) return done(err)
603+
server.close(done)
604+
}))
598605
.end()
599606
})
600607

@@ -617,7 +624,10 @@ describe('compression()', function () {
617624
.get('/')
618625
.set('Accept-Encoding', 'gzip')
619626
.request()
620-
.on('response', unchunk('gzip', onchunk, done))
627+
.on('response', unchunk('gzip', onchunk, function (err) {
628+
if (err) return done(err)
629+
server.close(done)
630+
}))
621631
.end()
622632
})
623633

@@ -640,7 +650,10 @@ describe('compression()', function () {
640650
.get('/')
641651
.set('Accept-Encoding', 'deflate')
642652
.request()
643-
.on('response', unchunk('deflate', onchunk, done))
653+
.on('response', unchunk('deflate', onchunk, function (err) {
654+
if (err) return done(err)
655+
server.close(done)
656+
}))
644657
.end()
645658
})
646659
})

0 commit comments

Comments
 (0)