Wednesday, 3 May 2017

nodejs write test cases for agenda ight-weight job scheduling library for Node.js

I'm using agenda https://github.com/rschmukler/agenda for job scheduling, code is given below

    agenda.define('send email report', {priority: 'high', concurrency: 10}, function(job, done) {
  var data = job.attrs.data;
  emailClient.send({
    to: data.to,
    from: 'example@example.com',
    subject: 'Email Report',
    body: '...'
  }, done);
});

agenda.on('ready', function() {
  agenda.schedule('in 20 minutes', 'send email report', {to: 'admin@example.com'});
  agenda.start();
});


agenda.on('success:send email report', function (task) {
        console.log('send email success report');
});

agenda.on('fail:send email report', function (err, task) {
       console.log('send email report fail');
});

I want to write test cases and want to check all the events like schedule,success,fail using mocha,chai.

Any help appreciated.



via saroj mandal

No comments:

Post a Comment