Skip to content

Commit de129c2

Browse files
committed
tests: run mocha with --no-exit to detect hangs
closes #3439
1 parent e3f7f51 commit de129c2

File tree

4 files changed

+30
-21
lines changed

4 files changed

+30
-21
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@
9090
],
9191
"scripts": {
9292
"lint": "eslint .",
93-
"test": "mocha --require test/support/env --reporter spec --bail --check-leaks test/ test/acceptance/",
94-
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/ test/acceptance/",
95-
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/ test/acceptance/",
96-
"test-tap": "mocha --require test/support/env --reporter tap --check-leaks test/ test/acceptance/"
93+
"test": "mocha --require test/support/env --reporter spec --bail --check-leaks --no-exit test/ test/acceptance/",
94+
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks --no-exit test/ test/acceptance/",
95+
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks --no-exit test/ test/acceptance/",
96+
"test-tap": "mocha --require test/support/env --reporter tap --check-leaks --no-exit test/ test/acceptance/"
9797
}
9898
}

test/middleware.basic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('middleware', function(){
2828
});
2929
});
3030

31-
request(app.listen())
31+
request(app)
3232
.get('/')
3333
.set('Content-Type', 'application/json')
3434
.send('{"foo":"bar"}')

test/res.format.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
var after = require('after')
23
var express = require('../')
34
, request = require('supertest')
45
, assert = require('assert');
@@ -168,21 +169,23 @@ function test(app) {
168169
.expect('hey', done);
169170
})
170171

171-
it('should set the correct charset for the Content-Type', function() {
172+
it('should set the correct charset for the Content-Type', function (done) {
173+
var cb = after(3, done)
174+
172175
request(app)
173176
.get('/')
174177
.set('Accept', 'text/html')
175-
.expect('Content-Type', 'text/html; charset=utf-8');
178+
.expect('Content-Type', 'text/html; charset=utf-8', cb)
176179

177180
request(app)
178181
.get('/')
179182
.set('Accept', 'text/plain')
180-
.expect('Content-Type', 'text/plain; charset=utf-8');
183+
.expect('Content-Type', 'text/plain; charset=utf-8', cb)
181184

182185
request(app)
183186
.get('/')
184187
.set('Accept', 'application/json')
185-
.expect('Content-Type', 'application/json');
188+
.expect('Content-Type', 'application/json; charset=utf-8', cb)
186189
})
187190

188191
it('should Vary: Accept', function(done){

test/res.sendFile.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe('res', function(){
102102
app.use(function (req, res) {
103103
setImmediate(function () {
104104
res.sendFile(path.resolve(fixtures, 'name.txt'));
105-
cb();
105+
server.close(cb)
106106
});
107107
test.abort();
108108
});
@@ -112,7 +112,8 @@ describe('res', function(){
112112
cb();
113113
});
114114

115-
var test = request(app).get('/');
115+
var server = app.listen()
116+
var test = request(server).get('/')
116117
test.expect(200, cb);
117118
})
118119

@@ -264,13 +265,14 @@ describe('res', function(){
264265
res.sendFile(path.resolve(fixtures, 'name.txt'), function (err) {
265266
should(err).be.ok()
266267
err.code.should.equal('ECONNABORTED');
267-
cb();
268+
server.close(cb)
268269
});
269270
});
270271
test.abort();
271272
});
272273

273-
var test = request(app).get('/');
274+
var server = app.listen()
275+
var test = request(server).get('/')
274276
test.expect(200, cb);
275277
})
276278

@@ -283,13 +285,14 @@ describe('res', function(){
283285
res.sendFile(path.resolve(fixtures, 'name.txt'), function (err) {
284286
should(err).be.ok()
285287
err.code.should.equal('ECONNABORTED');
286-
cb();
288+
server.close(cb)
287289
});
288290
});
289291
test.abort();
290292
});
291293

292-
var test = request(app).get('/');
294+
var server = app.listen()
295+
var test = request(server).get('/')
293296
test.expect(200, cb);
294297
})
295298

@@ -388,13 +391,14 @@ describe('res', function(){
388391
res.sendfile('test/fixtures/name.txt', function (err) {
389392
should(err).be.ok()
390393
err.code.should.equal('ECONNABORTED');
391-
cb();
394+
server.close(cb)
392395
});
393396
});
394397
test.abort();
395398
});
396399

397-
var test = request(app).get('/');
400+
var server = app.listen()
401+
var test = request(server).get('/')
398402
test.expect(200, cb);
399403
})
400404

@@ -407,13 +411,14 @@ describe('res', function(){
407411
res.sendfile('test/fixtures/name.txt', function (err) {
408412
should(err).be.ok()
409413
err.code.should.equal('ECONNABORTED');
410-
cb();
414+
server.close(cb)
411415
});
412416
});
413417
test.abort();
414418
});
415419

416-
var test = request(app).get('/');
420+
var server = app.listen()
421+
var test = request(server).get('/')
417422
test.expect(200, cb);
418423
})
419424

@@ -629,7 +634,7 @@ describe('res', function(){
629634
app.use(function (req, res) {
630635
setImmediate(function () {
631636
res.sendfile(path.resolve(fixtures, 'name.txt'));
632-
cb();
637+
server.close(cb)
633638
});
634639
test.abort();
635640
});
@@ -639,7 +644,8 @@ describe('res', function(){
639644
cb();
640645
});
641646

642-
var test = request(app).get('/');
647+
var server = app.listen()
648+
var test = request(server).get('/')
643649
test.expect(200, cb);
644650
})
645651

0 commit comments

Comments
 (0)