Question: I should run tests on node+express+mongoose+swagger app without mongodb, 
I need module to mock mongoose (only for tests).
I tried mock-mongoose and mockgoose, but I had errors :(
Maybe I failed.. or this modules can't help me
I hope for your ideas!

I created example skeleton:
<https://github.com/miroslav-grabinskiy/swagger-server-mock-tested>

I need to mock only in tests, and I don't need to test mongoose, like a:

```
Model.find()

```

I need test api (routes)
like in link

P.S. mock-mongoose not working with promises :(

Answer: 
I have found the solution - use [`mockgoose`](https://github.com/mockgoose/mockgoose):

```
"use strict";

const config = require(appRoot + '/config');
const Mongoose = require('mongoose').Mongoose;
const mongoose = new Mongoose();

const DB_NAME = "rbTest";
const DOCKER_MONGODB_URI = "mongodb://mongo:27017/" + DB_NAME;
const LOCAL_MONGODB_URI = "mongodb://localhost:27017/" + DB_NAME + "?socketTimeoutMS=120000";
const myMongo = process.env.DOCKER ? DOCKER_MONGODB_URI : LOCAL_MONGODB_URI;

mongoose.Promise = global.Promise;

if (process.env.NODE_ENV === 'testing') {
  const Mockgoose = require('mockgoose').Mockgoose;
  const mockgoose = new Mockgoose(mongoose);

  mockgoose.prepareStorage().then(function() {
    mongoose.connect(myMongo, function(err) {
      console.log('connected');
    });
  });
} else {
  mongoose.connect(myMongo, config.get('mongoose:options'));
}

module.exports = mongoose;

```
There are several libraries like mockgoose and mockingoose. I have tried several of them, and found a really simple solution, without additional dependencies.

I have a model Foo, which I add to exports in controller file:

```
//controller.js file
const Foo = mongoose.model('foo_collection', fooSchema);
exports.Foo = Foo;
exports.getFoo = query => Foo.find(query);

```

And in unit tests (for example, I use Chai), I import the model, and override "find" method:

```
//test-controller.js file
describe('some test', () => {
    beforeEach(() => {
        Foo.find = async () => [{foo: "bar"}];
    });

    it('should return foo bar', async () => {
        const fooBar = await controller.getFoo();
        assert(fooBar.foo === "bar");
    });
});

```