Mock kue in tests
mock-kue is a small mocking library for kue. It mocks out
process functions in kue, while maintaining the jobs in an internal array. You can then inspect the job count and run them at any given time. No connection to redis will be made by kue.
npm install mock-kue
To use, simply require the library:
You can inspect the job count as follows:
var kue = require'kue'jobs = kuecreateQueue;jobscreate'email'title: 'welcome email for tj'to: 'firstname.lastname@example.org'template: 'welcome-email'save;kuejobCount; // -> '1'
To process the jobs in the queue, you need to call the
returns a promise. The promise will be fulfilled once all the jobs are done processing. Here's an example:
kuedrainthenkuejobCount; // -> '0'// there was an error in processing the jobsconsole.logerrmessage;;
To clear a job, call the
jobscreatesave;kuejobCount; // -> '1'kueclear;kuejobCount; // -> '0'
To get the access to created jobs, call the
jobscreatesave;jobscreatesave;kuejobCount; // -> '2'kuegetJobs; // -> rturns the array of created jobs
Copyright (c) 2014 built.io team. This software is licensed under the MIT License.