我正在使用作业调度链接https://github.com/agenda/agenda的议程框架
调度作业它发送电子邮件给用户,它工作得很好,但我想为当前代码编写单元测试。感谢您的任何帮助
此作业作为示例节点jobname的进程运行
module.exports = function (agenda) {
agenda.define('sendemail', function (task, done) {
// Sending email logic here
})
// Success event when job run successfully,
agenda.on('success:sendemail', function (task) {
// send email to admin job run successfully
})
// Fail event when job failed
agenda.on('fail:sendemail', function (err, task) {
// send email to admin job failed
})
// Run sendemail job
agenda.on('ready', function () {
agenda.schedule('in 5 seconds', 'sendemail', {
time: new Date()
})
agenda.start()
})
}对于使用AWS SES服务发送电子邮件,sendemail具有不同的成功和失败状态。我想为上面的代码写单元测试,并想验证作业是成功还是失败。
发布于 2019-10-09 14:15:15
https://stackoverflow.com/questions/55360299
复制相似问题