mock-kue is a small mocking library for kue. It mocks out trigger
and 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.
Installation
Node.js:
npm install mock-kue
To use, simply require the library:
require('mock-kue');
Job Count
You can inspect the job count as follows:
var kue = jobs = kue; jobs; kue; // -> '1'
Processing Jobs
To process the jobs in the queue, you need to call the .drain()
method. .drain()
returns a promise. The promise will be fulfilled once all the jobs are done processing. Here's an example:
kue;
Clearing Jobs
To clear a job, call the .clear()
method:
jobs;kue; // -> '1'kueclear;kue; // -> '0'
Inspecting Jobs
To get the access to created jobs, call the .getJobs()
method:
jobs;jobs;kue; // -> '2'kue; // -> rturns the array of created jobs
License
Copyright (c) 2014 built.io team. This software is licensed under the MIT License.