chai-http
chai-http copied to clipboard
When running as Agent superagent defaults not set.
Code like this does not work:
var agent = chai.request.agent(urls.central).auth(su.username, su.password);
The default auth is NOT used in subsequent requests made with this agent, contrary to the superagent documentation at http://visionmedia.github.io/superagent/#agents-for-global-state
If you look at this line of SuperAgent:
https://github.com/visionmedia/superagent/blob/66aed3427f29bf0c09b1df0e7f8aa9f0e30732ab/lib/node/agent.js#L83
You see the call to _setDefaults.
The corresponding code in chai-http, https://github.com/chaijs/chai-http/blob/master/lib/request.js#L323 where it overrides the methods, is missing this call to setDefaults.
See PR #215 for my best suggestion, it fixes my use case but I am not familiar enough with superagent and chai-http to be totally sure.