mardi 3 septembre 2019

how to reset mongoose after using factory girl in test?

I'm using factory girl for creating my mongoose model instance in javascript. how can I make-instance just in the test environment?

when I use this factory. this method makes my instance really in MongoDB.

Factory.create('User', {name: 'WES'}, function(user) {
    // build a post and override title and content
    // console.log(user)
 });

this instance persistence in my DB after runnig test

User.find({ 'name': 'WES' }, 'name age', function (err, users) {
  // if (err) return handleError(err);
  console.log(users)
})

but it must be just in my test environment. I have to reset my mongo DB manually after factory or I can set it automatically?

Aucun commentaire:

Enregistrer un commentaire