Testing Queues

To test that specific jobs defined in a queue are working as expected, you can utilize the test.queues.job() method exported from @joystick.js/test:


import test from '@joystick.js/test';

test.that('queue runs the tasks_report job', async (assert = {}) => {
  await test.queues.job('tasks_report', {
    queue: 'tasks',
    payload: {
      week: 'january_4',
      user_id: 'abc123',

  const report = await process.databases.mongodb.collection('task_reports').findOne({
    user_id: 'abc123',
    week: 'january_4',

  assert.is(!!report, true);

Above, using the test.queues.job() method, we make a call directly to the tasks_report job in our tasks queue. To verify our call succeeded, we check that the expected side-effect of a report being added to the task_reports collection in our database exists for the user_id on the specified week.

The idea here is that when testing a job, we're not testing the queue functionality itself (i.e., that the job runs at a specific time). Instead, we're testing that the work being done at whatever time the job runs, runs as expected and creates the intended result.

API Reference


Function API

Function API

test.queues.job(job_name: string, options: object) => Promise;


  • job_name string Required

    The name of the job you're trying to test.

  • options object Required

    The options for the job to run.

    • queue string Required

      The name of the queue the job you're trying to test is defined on.

    • payload object

      An optional object of key/value pairs representing the payload for the job.

On This Page