0

I am creating the unit test in Node.Js using Mocha. In this application, MongoDB is used. To mock MongoDB, I am using Mockgoose. Following is the code

before(function (done) {
  mockgoose.prepareStorage().then(function () {
    mongoose.connect('mongodb://mongo.test/licenseDal', function (err) {
        var d = new Date();
        var today = d.toISOString();
        var newLic = new LicenseModel(licworking);
        newLic.createdDate = today;
        newLic.lastModifiedDate = today;
        return newLic.save().then(function (lic) {
          done(err);
        });
    });
  });
});

after(function (done) {
  mockgoose.helper.reset().then(() => {
      mongoose.connection.close().then(() => {
        done();
      });
  });
});

Here mockgoose.helper.reset() is not deleting the database.

Mockgoose version is 7.3.5

Twix
  • 392
  • 1
  • 12
  • 38

0 Answers0