node.js - How to put wait in mocha nodejs -
code -
.then (() => { console.log("wait"); settimeout(function(){console.log("wait process")},1500); this.timeout(2000); }) .then(() => { console.log("get abc"); return common.getapidata(url)})
now when run code logs data - wait abc wait process (the waits time specified above)
i want put timeout before calling getapidata method..
supposing using real promises, function should pass then
:
.then(function (value) { var p = new promise (); settimeout (function () { p.resolve(value) }, 2000) return p })
the next then
called once promise resolved.
Comments
Post a Comment