How to test code that uses mongodb as storage.
I have created a UserService
class which interacts with mongodb for
creating
, retrieving
, updating
and deleting
resources in users
collection. So in this repository explore different ways of testing the
functionality of that service.
yarn
ornpm
installed.- Latest
nodejs
installed. - Docker installed.
In order to run tests locally you need
- Run
yarn
ornpm install
for installing dependencies - Execute tests
- For mocks
yarn test:mock
ornpm run test:mock
- For docker
yarn test:docker
ornpm run test:docker
- For mongodb-memory-server
yarn test:memory
ornpm run test:memory
- For mocks
- Run jest in watch mode
yarn test:mock --watchAll
, useful for when writing tests. - Run docker compose from root folder
docker-compose -f ./docker-method/docker-compose.yaml <command> <flags>
MIT License