The common question that comes to mind is how to test asynchronous (Ajax) JavaScript code using JSTD. What has been mentioned in the chapter so far is how to perform unit testing for the synchronous JavaScript code. Fortunately, JSTD provides the AsyncTestCase
object in order to perform asynchronous JavaScript testing (Ajax testing). In the following section, you will understand how to work with the AsyncTestCase
object in order to develop asynchronous tests in JSTD.
AsyncTestCase
extends TestCase
by allowing the test methods to have a queue
parameter. The queue
parameter can contain a list of inline functions (steps) that are executed in sequence. Every inline function has a callbacks
parameter that allows creating different callbacks for testing the asynchronous operations. JSTD mainly has two types of callbacks: