How to unit test a method which connects to mongo, without actually connecting to mongo?
问题 I'm trying to write a test to test a method that connects to mongo, but I don't actually want to have to have mongo running and actually make a connection to it to have my tests pass successfully. Here's my current test which is successful when my mongo daemon is running. describe('with a valid mongo string parameter', function() { it('should return a rejected promise', function(done) { var con = mongoFactory.getConnection('mongodb://localhost:27017'); expect(con).to.be.fulfilled; done(); });