Post

Any backend devs have tips or opinions on testing API endpoints that send messages to queues for processing? I feel like I’ve reinvented this everywhere I’ve worked and never loved a pattern I came up with

My favourite way of doing this was at Nebula. We used Django and Celery. Celery has a mode where all queue operations become synchronous instead of being queued. This was very useful in tests, I don’t recall us running into problems with it.

0 reposts1 like

I’m not familiar with that option, I’ll have to dive into the docs! We have a custom Celery wrapper we use to call tasks and that decides on doing the task inline, async, or not at all. We’re starting to use NestJS so I’m wondering if there are some things we can bring over to that framework

Hm yeah their approach looks somewhat complex! Seems like they’re recommending a way to do a full e2e test including the message broker and result backend, which is more than I’d need, since I trust my broker to just work (maybe not the smartest approach but 🤷)