supertest
Advanced tools
Comparing version 0.6.0 to 0.6.1
0.6.1 / 2013-06-02 | ||
================== | ||
* fix: EADDRINUSE errnos, use ephemeral ports now | ||
* fix: handling of socket errors | ||
0.6.0 / 2013-04-15 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -14,8 +14,2 @@ | ||
/** | ||
* Starting port. | ||
*/ | ||
var port = 3456; | ||
/** | ||
* Expose `Test`. | ||
@@ -65,6 +59,6 @@ */ | ||
var addr = app.address(); | ||
var portno = addr ? addr.port : port++; | ||
if (!addr) app.listen(portno); | ||
if (!addr) app.listen(0); | ||
var port = app.address().port; | ||
var protocol = app instanceof https.Server ? 'https' : 'http'; | ||
return protocol + '://127.0.0.1:' + portno + path; | ||
return protocol + '://127.0.0.1:' + port + path; | ||
}; | ||
@@ -125,3 +119,4 @@ | ||
var end = Request.prototype.end; | ||
end.call(this, function(res){ | ||
end.call(this, function(err, res){ | ||
if (err) return fn(err); | ||
self.assert(res, fn); | ||
@@ -128,0 +123,0 @@ }); |
{ | ||
"name": "supertest", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "Super-agent driven library for testing HTTP servers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,2 +6,3 @@ | ||
, path = require('path') | ||
, should = require('should') | ||
, express = require('express'); | ||
@@ -95,2 +96,3 @@ | ||
.end(function(err, res){ | ||
if (err) return done(err); | ||
res.should.have.status(200); | ||
@@ -141,2 +143,17 @@ res.text.should.equal('hey'); | ||
it('should handle socket errors', function(done) { | ||
var app = express(); | ||
app.get('/', function(req, res){ | ||
res.destroy(); | ||
}); | ||
request(app) | ||
.get('/') | ||
.end(function(err) { | ||
should.exist(err); | ||
done(); | ||
}); | ||
}) | ||
describe('.expect(status[, fn])', function(){ | ||
@@ -143,0 +160,0 @@ it('should assert the response status', function(done){ |
22808
13
590