Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bull
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 175
    • Issues 175
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 9
    • Merge requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OptimalBits
  • bull
  • Issues
  • #1548
Closed
Open
Issue created Nov 07, 2019 by Administrator@rootContributor

Queue#drain method for better job tests

Created by: bogdan

Description

I want to be concise in my tests related to queue.

Using Queue#process in tests lead to a complex code structure - similar to the one used in bull tests like here: https://github.com/OptimalBits/bull/blob/develop/test/test_queue.js#L111

This can got especially complex when job handlers create other jobs inside.

The easier way of doing things would be to have drain method that suppose to process all jobs within the queue and return a promise that resolves when all jobs are processed:

queue.add({hello: 'world').then(() => queue.drain()).then(() => {
  expect(something).toEqual(something)
});

The even simpler way to write tests would be use the #inline method that makes all jobs processing inline:

queue.inline = true
queue.add({hello: 'world'}).then(() => {
  // expecting the job is already processed
})

Inspired by: Sidekiq testing guide which has so much more staff to facilitate automated tests.

Are you interested in adding such functionality?

Assignee
Assign to
Time tracking