I have a function I would like to test:
var mailServerOptions = {....};
var transporter = nodemailer.createTransport(mailServerOptions);
exports.sendTemplateEmail = (to, template, data) => {
var mailOptions = {....}
return new Promise((resolve, reject) => {
transporter.sendMail(mailOptions, (err, result) => {
if (err) {
return reject(err)
}
return resolve(result);
});
});
}
How can I stub the transporter.sendMail in this situation? I found this post but it doesn't really fit what I'm trying to do.
I can move the send part to it's own function and stub that if I really have to, but it would be nice if I didn't have to go that route.