Tuesday, 14 March 2017

[SOLVED]Mockgoose is downloading 234mb when running mockgoose.prepareStorage

I have a node application with access to mongodb thrown mongoose tested with mocha and mockgoose. I moved recently to mockgoose 7.0.5. I followed the getting started on github and upped my mocha timeout to 2 minutes.
Here are my before functions in my tests :
import mongoose from 'mongoose';
var Mockgoose = require('mockgoose').Mockgoose;
[...]

const mockgoose = new Mockgoose(mongoose);

before(function(done) {
  try {
    console.log('BEFORE prepareStorage');
    mockgoose.prepareStorage().then(() => {
    console.log('IN prepareStorage');
      mongoose.connect('mongodb://example.com/TestingDB', function(err) {
        done(err);
      });
    }).catch((error) => {
      done(error);
    });
  } catch(e) {
    done(e);
  }
  console.log('AFTER prepareStorage');  
});

beforeEach(function(done) {
  mockgoose.helper.reset();
  done();
});

When I run the tests, during the mockgoose.prepareStorage step, mockgoose seems to be downloading something.
BEFORE prepareStorage
AFTER prepareStorage
Completed: 0.1 % (0.2mb / 234.3mb

I guess it has something to do with the requested 2 minutes timeout.
My questions / problems are :
  • Does anybody know what mockgoose is downloading ? (I don't remember this behaviour with previous versions of mockgoose)
  • Does mockgoose need this download at each run (npm test) or will the result be reused in the next runs (npm test) ?
  • Can I prevent him to download something. Ideally, I would like to run my unit test in a sandbox env, with no access to the web (in a docker). Can I download the 234mb somewhere and ask mockgoose to reuse it ?
Thanks


via Julien TASSIN

No comments:

Post a Comment