chai-http icon indicating copy to clipboard operation
chai-http copied to clipboard

When running as Agent superagent defaults not set.

Open bkuker opened this issue 6 years ago • 1 comments

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.

bkuker avatar Jun 29 '18 16:06 bkuker

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.

bkuker avatar Jun 29 '18 16:06 bkuker