I have something like:
sandbox.stub(rp, 'get').resolves(successResponse)
which returns my custom response when it hits this code:
return await rp.get(url, options)
But how can I do something like this:
sandbox.stub(rp).resolves(successResponse)
Which can return a custom response when it hits this code?
return await rp(url, options)
When I attempt "stubbing" the entire object, I get this error when I run the test:
TypeError: Attempted to wrap undefined property undefined as function
at wrapMethod (node_modules\sinon\lib\sinon\util\core\wrap-method.js:70:21)
at stub (node_modules\sinon\lib\sinon\stub.js:58:44)
at Object.stub (node_modules\sinon\lib\sinon\collection.js:93:33)
rp
is request-promise-native, which wraps request