I need to test the server, but on the local machine, the functionality of sending letters does not work, so to send letters you need to make a stub using SinonJS.
The problem is that for the first time I encountered such a task and testing. In principle, what I figured out, but when it comes to the realization of the problem, I can’t figure out exactly where to create the mock and how to create it.
Maybe someone has illustrative code examples or someone can show me exactly how to do it?
Here is the function that needs to be locked, it should send a letter to activate the account, but on the local machine it does not need to be configured, just need to somehow make a stub.
var originalFunction = function(event){ return Bb .try(() => { let templateData = { appName: config.app.title, name: event.user.name, token: event.user.emailVerificationToken }; return verificationTpl(templateData); }) .then(function (emailHtml) { var mailOptions = _.extend({ to: event.user.username, html: emailHtml }, verificationEmailOptions, emailConfig.options); log.info('Sending mail to: ' + mailOptions.to); var retValue = emailConfig.transport.sendMailAsync(mailOptions); return retValue; }) .catch((err) => { log.error('Cannot send mail: ' + err); }); };