Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fix #39 .expect(status[, fn]) expect undefined response body #41

Closed
wants to merge 1 commit into from

1 participant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 1 deletion.
  1. +1 −1  lib/test.js
  2. +15 −0 test/supertest.js
View
2  lib/test.js
@@ -93,7 +93,7 @@ Test.prototype.expect = function(a, b, c){
if ('number' == typeof a) {
this._status = a;
// body
- if ('function' != typeof b) this._bodies.push(b);
+ if ('function' != typeof b && b !== undefined) this._bodies.push(b);
return this;
}
View
15 test/supertest.js
@@ -202,6 +202,21 @@ describe('request(app)', function(){
.expect('{"foo":"bar"}', done);
})
+ it('should assert the response text after expect(status)', function(done){
+ var app = express();
+
+ app.set('json spaces', 0);
+
+ app.get('/', function(req, res){
+ res.send({ foo: 'bar' });
+ });
+
+ request(app)
+ .get('/')
+ .expect(200)
+ .expect('{"foo":"bar"}', done);
+ })
+
it('should assert the parsed response body', function(done){
var app = express();
Something went wrong with that request. Please try again.