'How to test server code that relies on a database?

I have a NodeJS/MongoDB app. There are lots of functions, and I have a bunch of unit tests to test specifically logic of some functions.

There is also code that uses Agenda (task scheduling library) which itself requires MongoDB for persistance. How do I set up test environment, so that both, unit tests and Agenda/MongoDB code is tested? Should I run all the tests in a Docker environment, or separate simple unit tests from Agenda/MongoDB tests?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source