using superagent-mock with agent
aldoshin opened this issue · 1 comments
aldoshin commented
Hi there,
I started using and superagent agent (ladjs/superagent#1302) to have a general interceptor for my request
const requestAgent = request.agent().use(AuthIntercept);
But now I do not know how to mock that agent using superagent-mock. if I do:
import requestAgent from '../../utils/superagentInterceptor';
import superagentMock from 'superagent-mock';
superagentMockTest = superagentMock(requestAgent, configGood);
when running the test I get the error undefined is not an object (evaluating 'Request.prototype')
. I don't know if I am using it wrong or still does not have support to mock agents . Please advice
aldoshin commented
I ended up using the plugin https://github.com/koenpunt/superagent-use, I saw in superagent-mock code it overrides the superagent Request and the Agent object does not have that, instead the other lib just extends the superagent object.