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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.