Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gkampitakis/mongodb-jest-testing
Tests with jest and mongodb
https://github.com/gkampitakis/mongodb-jest-testing
docker-compose jest learning-by-doing mongodb testing typescript
Last synced: 6 days ago
JSON representation
Tests with jest and mongodb
- Host: GitHub
- URL: https://github.com/gkampitakis/mongodb-jest-testing
- Owner: gkampitakis
- License: mit
- Created: 2021-09-25T20:24:34.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2021-12-14T22:48:03.000Z (almost 3 years ago)
- Last Synced: 2023-03-06T06:37:13.288Z (over 1 year ago)
- Topics: docker-compose, jest, learning-by-doing, mongodb, testing, typescript
- Language: TypeScript
- Homepage:
- Size: 64.5 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mongodb and Jest Testing
[![Ask Me Anything !](https://img.shields.io/badge/Ask%20me-anything-1abc9c.svg)](https://twitter.com/g_kampitakis)
How to test code that uses mongodb as storage.
## Description
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.## Development
### Prerequisites
- `yarn` or `npm` installed.
- Latest `nodejs` installed.
- Docker installed.### Run
In order to run tests locally you need
- Run `yarn` or `npm install` for installing dependencies
- Execute tests
- For mocks `yarn test:mock` or `npm run test:mock`
- For docker `yarn test:docker` or `npm run test:docker`
- For mongodb-memory-server `yarn test:memory` or `npm run test:memory`## Useful commands
- 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 `## License
MIT License