I have been looking for this all over the place. Some people seem to do
mongoose.connect('mongodb://localhost/test');
and go on with their describe
calls. What about the async waiting, though?
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function (callback) {
// yay!
});
How should I use this connection in Mocha tests? Should I put all my tests in the callback? Should I wrap the waiting-for-connection code in a unit test? Will the connection persist across describe
s and it
s?
Aucun commentaire:
Enregistrer un commentaire