Node.js 在测试中使用factory girl后如何重置猫鼬?
我正在使用javascript创建mongoose模型实例。如何在测试环境中创建实例 当我使用这个工厂的时候。这种方法使我的实例真正位于MongoDB中Node.js 在测试中使用factory girl后如何重置猫鼬?,node.js,express,testing,mongoose,factory,Node.js,Express,Testing,Mongoose,Factory,我正在使用javascript创建mongoose模型实例。如何在测试环境中创建实例 当我使用这个工厂的时候。这种方法使我的实例真正位于MongoDB中 Factory.create('User', {name: 'WES'}, function(user) { // build a post and override title and content // console.log(user) }); 运行测试后,此实例在my DB中持久化 但它必须在我的测试环境中。我必须
Factory.create('User', {name: 'WES'}, function(user) {
// build a post and override title and content
// console.log(user)
});
运行测试后,此实例在my DB中持久化
但它必须在我的测试环境中。我必须在出厂后手动重置我的mongo DB,或者我可以自动设置它?我刚刚开始使用factory girl,但我相信
User.save()
会在factory.create()
中调用。运行测试后,尝试使用factory.cleanUp()
。
User.find({ name: 'WES' }, 'name age', function (err, users) {
// if (err) return handleError(err);
console.log(users)
})