I'm having difficulty mocking an external dependency in node.js (ts-node) with Jest (ts-jest). The dependency is node-chargebee (https://github.com/chargebee/chargebee-node).
The lib exports all its endpoints in a prototype class new RequestWrapper() and the method attached to this I want to mock (the method that calls the chargebee API server) is .request() (i.e. RequestWrapper.prototype.request = function(callBack, envOptions)).
So a full call on node-chargebee would be like chargebee.plan.retrieve("id").request((result, error) => {...})
As I say, I'm trying to mock the .request() and I'm sure I'm being stupid in not knowing how to do this and missing something really simple?
In short, I simply want to avoid actual calls to request() and either ignore the response or stub the (result, error) response out?
Aucun commentaire:
Enregistrer un commentaire