elliotf / mocha-mongoose

test helpers for using mongodb with mocha
MIT License
107 stars 21 forks source link

Is it possible to change return the Promise object? #9

Closed holyshared closed 8 years ago

holyshared commented 9 years ago

I think that when you to return the Promise object, become better. For example, will be as follows.

clearDB = require('mocha-mongoose')(dbURI) //Return promise object  
clearDB.then(function() {
  //do something
}).error(function(error) {
  //do something
})

What do you think?.

elliotf commented 9 years ago

I welcome pull requests! I don't actually use this library anymore, so any help you can provide is welcome. :)

elliotf commented 8 years ago

I'm going to go ahead and close this issue. Please feel free to reopen or create a pull request. Thank you!

cellis commented 7 years ago

In case anyone finds this, ( and @elliotf perhaps it could be in the readme ), I was able to get promises working with code like this:

const Q = require('q') // or import Q from 'q';
const promise = Q.nfcall(clearDB);

// example
// Q.nfcall(clearDB).then(function() {
//  
//}).catch(function(err) { 
// handle err here
//});

Also works in jest 🎉