javascript - mocha test when callback is run -


i testing api has callback inside callback @ end of function. want wrap in test verify object correct doesn't seem working. callbackend() gets called that's it.

in library on script load success:

function callback() {   // populate gpt object   if(typeof callbackend === 'function') {     callbackend();   } } 

mocha.js test:

"use strict"; (function() {    describe("callback success", function() {     function callbackend() {        console.log('callbackend() called');        it('gpt returned advars', function() {         expect(object.keys(someobj).length).to.begreaterthan(0);         console.log('gpt loaded successfully, ' + object.keys(someobj).length);       });      }   });  })(); 

there goes, describe -> -> custom callback function -> done();

 "use strict"; (function() {    describe("callback success", function() {        it('gpt returned advars', function(done) {          function callbackend() {           expect(object.keys(someobj).length).to.not.equal(0);           console.log('gpt loaded successfully, ' + object.keys(someobj).length);           done();         }        });   }); })(); 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -