Promise object is already supported by all the major browsers including Chrome, Firefox, and Safari.
Despite making asynchronous code simpler, dealing with promises in unit tests is a hassle. You need to wire your test’s assertions into the callbacks of the promise, which adds extra code into the test. In this way the test itself becomes a bit complicated and it’s harder to see what’s happening.
In this article, I’ll show you how to fix this issue and discuss about useful patterns which are able to simplify common promise-scenarios in tests’ stage.
I’ve created an example project that you can download from my website which shows the techniques introduced in this article.