MockoDB
In-memory mock for MongoDB in unit tests.
Inspired by mongo-unit.
Installation
MockoDB is available on NPM.
yarn add mockodbnpm install --save mockodb
Usage
;;
You can also control individual databases.
;;
Preloading
Note that MockoDb.boot()
might attempt to download the MongoDB binaries on the
first run. You can preload those libraries explicitly before your tests run
using the preload()
function:
; describe"test suite",;
Alternatively, for a more direct use inside your CI's script, this package
exposes the mockodb-preload
command in its bin:
yarn installmockodb-preloadyarn test
Download Directory
MockoDB will download the MongoDB binaries into its folder. Therefore you can
simply cache your node_modules
on your CI, making it download the MongoDB
binaries once on the first run and whenever you clear your cache.