Skip to content

Commit

Permalink
tests: run mocha with --no-exit to detect hangs
Browse files Browse the repository at this point in the history
closes #3439
  • Loading branch information
dougwilson committed Oct 1, 2017
1 parent e3f7f51 commit de129c2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@
],
"scripts": {
"lint": "eslint .",
"test": "mocha --require test/support/env --reporter spec --bail --check-leaks test/ test/acceptance/",
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/ test/acceptance/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/ test/acceptance/",
"test-tap": "mocha --require test/support/env --reporter tap --check-leaks test/ test/acceptance/"
"test": "mocha --require test/support/env --reporter spec --bail --check-leaks --no-exit test/ test/acceptance/",
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks --no-exit test/ test/acceptance/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks --no-exit test/ test/acceptance/",
"test-tap": "mocha --require test/support/env --reporter tap --check-leaks --no-exit test/ test/acceptance/"
}
}
2 changes: 1 addition & 1 deletion test/middleware.basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('middleware', function(){
});
});

request(app.listen())
request(app)
.get('/')
.set('Content-Type', 'application/json')
.send('{"foo":"bar"}')
Expand Down
11 changes: 7 additions & 4 deletions test/res.format.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

var after = require('after')
var express = require('../')
, request = require('supertest')
, assert = require('assert');
Expand Down Expand Up @@ -168,21 +169,23 @@ function test(app) {
.expect('hey', done);
})

it('should set the correct charset for the Content-Type', function() {
it('should set the correct charset for the Content-Type', function (done) {
var cb = after(3, done)

request(app)
.get('/')
.set('Accept', 'text/html')
.expect('Content-Type', 'text/html; charset=utf-8');
.expect('Content-Type', 'text/html; charset=utf-8', cb)

request(app)
.get('/')
.set('Accept', 'text/plain')
.expect('Content-Type', 'text/plain; charset=utf-8');
.expect('Content-Type', 'text/plain; charset=utf-8', cb)

request(app)
.get('/')
.set('Accept', 'application/json')
.expect('Content-Type', 'application/json');
.expect('Content-Type', 'application/json; charset=utf-8', cb)
})

it('should Vary: Accept', function(done){
Expand Down
30 changes: 18 additions & 12 deletions test/res.sendFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('res', function(){
app.use(function (req, res) {
setImmediate(function () {
res.sendFile(path.resolve(fixtures, 'name.txt'));
cb();
server.close(cb)
});
test.abort();
});
Expand All @@ -112,7 +112,8 @@ describe('res', function(){
cb();
});

var test = request(app).get('/');
var server = app.listen()
var test = request(server).get('/')
test.expect(200, cb);
})

Expand Down Expand Up @@ -264,13 +265,14 @@ describe('res', function(){
res.sendFile(path.resolve(fixtures, 'name.txt'), function (err) {
should(err).be.ok()
err.code.should.equal('ECONNABORTED');
cb();
server.close(cb)
});
});
test.abort();
});

var test = request(app).get('/');
var server = app.listen()
var test = request(server).get('/')
test.expect(200, cb);
})

Expand All @@ -283,13 +285,14 @@ describe('res', function(){
res.sendFile(path.resolve(fixtures, 'name.txt'), function (err) {
should(err).be.ok()
err.code.should.equal('ECONNABORTED');
cb();
server.close(cb)
});
});
test.abort();
});

var test = request(app).get('/');
var server = app.listen()
var test = request(server).get('/')
test.expect(200, cb);
})

Expand Down Expand Up @@ -388,13 +391,14 @@ describe('res', function(){
res.sendfile('test/fixtures/name.txt', function (err) {
should(err).be.ok()
err.code.should.equal('ECONNABORTED');
cb();
server.close(cb)
});
});
test.abort();
});

var test = request(app).get('/');
var server = app.listen()
var test = request(server).get('/')
test.expect(200, cb);
})

Expand All @@ -407,13 +411,14 @@ describe('res', function(){
res.sendfile('test/fixtures/name.txt', function (err) {
should(err).be.ok()
err.code.should.equal('ECONNABORTED');
cb();
server.close(cb)
});
});
test.abort();
});

var test = request(app).get('/');
var server = app.listen()
var test = request(server).get('/')
test.expect(200, cb);
})

Expand Down Expand Up @@ -629,7 +634,7 @@ describe('res', function(){
app.use(function (req, res) {
setImmediate(function () {
res.sendfile(path.resolve(fixtures, 'name.txt'));
cb();
server.close(cb)
});
test.abort();
});
Expand All @@ -639,7 +644,8 @@ describe('res', function(){
cb();
});

var test = request(app).get('/');
var server = app.listen()
var test = request(server).get('/')
test.expect(200, cb);
})

Expand Down

0 comments on commit de129c2

Please sign in to comment.