javascript - Mocha js Calling After() too Soon? -


new mocha unit testing, have few mocha examples running fine, have been trying hours 1 run , no matter do, after() called way earlier feel should. here's example:

var dummydata = require('./dummydata.js')  describe('mochatest', function() {      after(function(done) {         dummydata.cleandb(function(){             done();         })     });      it('should hit db dummy data , send', function(done) {          dummydata.createdummydata(function(data1, data2, lookup) {             lookup.lookup({                 data1: data1,                 data2: data2             }, function(err, result) {                 done();             });         });     }); }) 

and in dummydata.js:

exports.createdummydata = function(cb){    dosomestuff(function (err, patient) {      // connect db, data pass.         var lookup = require(./lookup.js);         cb(data1, data2, lookup);     }) }  exports.cleandb = function(cb) {    // clear db connections.    cb(); } 

the problem right after test run, after() function gets called , lookup function can't hit db, because db connection has been cleared. why after being called early, shouldn't called until statement calls done() right?


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -