Client-Side Callbacks

Like the server side, a number of libraries used on the client side also rely on callbacks. Even if an asynchronous function runs within browsers, verifying its behavior isn’t much different. You can use the techniques you learned for server-side code for client-side code as well.

We’ll practice testing client-side asynchronous functions using an example that gets the current location of the user, using the geolocation API. The project for this example is located under the tdjsa/async/geolocation directory in your workspace. This project will make use of Mocha, Chai, Karma, and the plugins that Karma needs to integrate with these tools and with the browser. For a complete list of tools, take a look at the package.json

Get Test-Driving JavaScript Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.