Monday, 29 May 2017

How do I populate a mongodb in nightwatch?

I'm trying to populate a mongodb database in my nightwatch tests. What is the correct way to go about this? This is the gist of what I am trying:

var popDB = function(){
  var user = new User({
    username: globals.vals.users['1'].name,
    _id: globals.vals.users['1'].id,
    email: globals.vals.users['1'].email,
    password: globals.vals.password
  })
  user.save( function(res, err){
    if (!err) return true
    return false
  })  
})


client.executeAsync(function (popDB, data, done) {
  done(popDB())
}

My mongo shell shows nada. Additionally, this may work to populate the db eventually, but how do I go about clearing it?



via phillercode

No comments:

Post a Comment