I've been stuck a couple of hours with setting up asynchronous tests now, and I think the documentation needs to be updated. The following code can be found in the documentation:
describe('#find()', function(){
it('respond with matching records', function(done){
db.find({ type: 'User' }, function(err, res){
if (err) return done(err);
res.should.have.length(3);
done();
})
})
})
The assertion here will crash Mocha, because the AssertionError won't be caught. It should be wrapped in a try-catch statement, it would be good if the official documentation shows that :)
Just tested the example with the recent mongodb, should and mocha. It works fine. If you insist, open this issue again, but provide detailed information on your specific case.
I'm seeing something similar - the mocha timeout is getting hit, as the AssertionError looks to be being caught by mongo: https://github.com/mongodb/node-mongodb-native/blob/V1.3.19/lib/mongodb/connection/base.js#L384
Stack Frames:
Base._callHandler(), base.js:384
Server.connect.connectionPool.on.server._serverState(), server.js:472
MongoReply.parseBody(), mongo_reply.js:68
Server.connect.connectionPool.on.server._serverState(), server.js:430
I failed to create a simple test case - they all worked ok.
I did however find a workaround - wrap your assertions in a process.nextTick().
I downgraded to [email protected] and that worked ok.
hmm mocha should be catching those with uncaughtException and mapping them to the correct test case