Automattic / Automattic/kue

Testing when using Kue

Open
#627 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
9.4k
Forks
858
PR merge metrics
No merged PRs in 30d

Description

Kue has a testing mode, but it seems to lack certain features. Given I have a component which adds jobs to the queue and waits for their completion to do something with the result. I want to test this component in isolation without accessing Redis (using the test mode). This is not possible right now as far as I can see it.

The following JavaScript snippet will log `The Job is really done`:

``` js
var queue = require('kue').createQueue();

queue.process('myJob', function(job, done) {
done(null, 'The Job is really done');
});

var job = queue.createJob('myJob', {});
job.save();

job.on('complete', function(result) {
console.log(result);
});
```

The same snippet, using test mode, will not log anything:

``` js
var queue = require('kue').createQueue();

queue.testMode.enter();

queue.process('myJob', function(job, done) {
done(null, 'The Job is really done');
});

var job = queue.createJob('myJob', {});
job.save();

job.on('complete', function(result) {
console.log(result);
});
```

I guess the reason for this is that event handling is done via Redis pub-sub. The question is: How do you test your apps? Are you using a Redis instance during testing?

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the two snippets from the issue, then inspect Kue's test-mode and completion-event handling. Done means the test-mode version emits the complete event and result without accessing Redis.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, redis
Domain
backend, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.