# Testing with mongodb-memory-server

mongodb-memory-server starts a real, throwaway MongoDB for a test file, so before starts it, beforeEach gives every test the same fresh data, Supertest tests the whole API against it, and after stops it, with your own data never touched.

![Cheat sheet: Testing with mongodb-memory-server](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/9d90bb7fbb944d8f86b9d1d7db095b29.webp)

- Category: Node.js
- Level: Journeyman
- Tags: Integration Test, mongodb, mongodb-memory-server, node:test, nodejs, Test Isolation, unit testing
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/node-mongodb-memory-server-tests-cheat-sheet
