Node js stubbing issue

Viewed 15

So, I am trying to write unit tests for a lambda handler. It is just a classic exports.handler function expression.I require this using const {handler}=require( "."). Just after requiring it, there's a const which makes an api call to a third party service to obtain few details for further processing.

At my unit testing side, I am running into Assertion error of not passing the required key for that third party service.

const analytics = new Analytics(process.env.yourWritekey, analyticsOptions);

exports.handler=async(event,context,callback)=>{

  //this part is business logic
}

So my question is , how did I just test the handler by stubbing the third party api call?

0 Answers
Related