Answers for "how to run mocha tests on asynchronous functions in script"

0

how to run mocha tests on asynchronous functions in script

// async/await
it('responds with matching records', async function() {
  const users = await db.find({ type: 'User' });
  users.should.have.length(3);
});

// promise.then()
it('should save without error', function(done) {
  var user = new User('Luna');
  user.save(function(err) {
    if (err) done(err);
    else done();
  });
});
Posted by: Guest on March-29-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language