Jan 25, 2014

[Solved] NodeUnit does not finish when connected to Mongo DB

Posted Jan 25, 2014
When running NodeUnit tests and your tests are connected to Mongo DB, the tests do not end and it just hangs there. The fix is to close the connection on NodeUnit's tearDown function.

Example below is using Mongoose' disconnect function to close the connection after NodeUnit tests are done:
var mongoose = require('mongoose');
exports.tearDown = function(ok){
    mongoose.disconnect(function(err){
        if(err) {
            console.error(err);
            return;
        }
    });
    ok();
};



2 comments:

  1. maybe you have other idle processes, like is your app server listening. If so, you should also stop that.

    ReplyDelete