Mockgoose is an in memory database mock to allow for testing of applications that rely on Mongoose.

Please Share on Twitter if you like #mockgoose

Mockgoose provides test database by spinning up mongod on the back when mockgoose.connect call is made. By default it is using in memory store which does not have persistance.

To install the latest official version, use NPM:

npm install mockgoose --save-dev

You simply require Mongoose and Mockgoose and wrap Mongoose with Mockgoose.

var mongoose = require('mongoose');
var mockgoose = require('mockgoose');


Once Mongoose has been wrapped by Mockgoose connect() will be intercepted by Mockgoose so that no MongoDB instance is created.

var Mongoose = require('mongoose').Mongoose;
var mongoose = new Mongoose();
var mockgoose = require('mockgoose');
before(function(done) {
    mongoose.connect('mongodb://', function(err) {
describe('...', function() {
    it("...", function(done) {
        // ...