Skip to content

Instantly share code, notes, and snippets.

@misterdjules
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save misterdjules/9ff53baa61efbb5f9256 to your computer and use it in GitHub Desktop.
Save misterdjules/9ff53baa61efbb5f9256 to your computer and use it in GitHub Desktop.
Using server.address().address in test/req.ip.js test for express
diff --git a/test/req.ip.js b/test/req.ip.js
index f24401c..a17b924 100644
--- a/test/req.ip.js
+++ b/test/req.ip.js
@@ -60,11 +60,14 @@ describe('req', function(){
res.send(req.ip);
});
- request(app)
- .get('/')
- .set('X-Forwarded-For', 'client, p1, p2')
- .expect(isLoopbackIp)
- .end(done);
+ var server = app.listen(function() {
+ request(app)
+ .get('/')
+ .set('X-Forwarded-For', 'client, p1, p2')
+ .expect(server.address().address)
+ .end(done);
+ });
+
})
})
})
@@ -79,10 +82,13 @@ describe('req', function(){
res.send(req.ip);
});
- request(app)
- .get('/')
- .expect(isLoopbackIp)
- .end(done);
+ var server = app.listen(function() {
+ request(app)
+ .get('/')
+ .expect(server.address().address)
+ .end(done);
+ });
+
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment