Just started to learn JavaScript, I need your help:
describe('Test Suite #1', function(){ it('Check URL Errors', function() { assert.equal(checkStatusCode(URL), true); }); }); The problem with assert.equal(...) is that the comparison is done before the function is completed. The question is how to get around this moment? How are such moments resolved when I need to get the result of a function, and then perform actions with it? Do you need promises for this or are there other options?
Thank!
@vp_arth, but do not tell me with an example, how to make a nodejs-style function with a callback from this?
function checkStatusCode(url, cb){ if (url == 'right url'){ cb(null, true); } else{cb(null, false);} }
return new Promise(...)is one thing, iffunction(url, next)is another. My question is what do you call the result of a function ? - vp_arth