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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -