Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pawap90/test-mongoose-inmemory
A sample project that demonstrates how to test mongoose operations through jest with an in-memory database.
https://github.com/pawap90/test-mongoose-inmemory
jest mongodb mongoose nodejs testing
Last synced: about 1 month ago
JSON representation
A sample project that demonstrates how to test mongoose operations through jest with an in-memory database.
- Host: GitHub
- URL: https://github.com/pawap90/test-mongoose-inmemory
- Owner: pawap90
- Created: 2019-10-26T22:27:52.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T04:23:31.000Z (almost 2 years ago)
- Last Synced: 2023-06-14T17:50:17.403Z (over 1 year ago)
- Topics: jest, mongodb, mongoose, nodejs, testing
- Language: JavaScript
- Size: 292 KB
- Stars: 42
- Watchers: 1
- Forks: 15
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
A Node.js + Mongoose + Jest sample project that demonstrates **how to test mongoose operations using Jest with an in-memory database**.
>This repo was build as an example for my article [Testing Node.js + Mongoose with an in-memory database](https://dev.to/paulasantamaria/testing-node-js-mongoose-with-an-in-memory-database-32np).
# Dependencies
What you need to run this project:
- Node.js(MongoDB is not required because it'll run in memory, handled by the package `mongodb-memory-server`).
# Try it out
## 1. Install dependencies
```
npm install
```## 2. Run tests
```
npm test
```# Contribute
Feel free to contribute to this project either by leaving your comments and suggestions in the Issues section or creating a PR. More and diverse test examples are always useful. Make sure to take a look at Jest docs and the existent examples to avoid repeating.# Tools
Main tools used in this project:- [Mongoose](https://mongoosejs.com/)
- [Jest](https://jestjs.io/)
- [mongodb-memory-server package by @nodkz](https://github.com/nodkz/mongodb-memory-server)> Also take a look at [mongodb-memory-server-global](https://github.com/nodkz/mongodb-memory-server#mongodb-memory-server-global) to download mongod's binary globally and [mongodb-memory-server-core](https://github.com/nodkz/mongodb-memory-server#mongodb-memory-server-core) if you'll run the test on a server that already has mongod installed.