I am using npm request, How to mock request.post I need to test the error scenario, statuscode not 200 scenario and the success flow.
1 request.post(reqObject, (error: Error, response: any, body: any) => {
2 if (error) { return reject(error); }
3 if (response.statusCode !== 200) {
4 return reject('Invalid status code <' + response.statusCode + '>');
5 }
6 return resolve(JSON.parse(body));
7 });