Performance Zone is brought to you in partnership with:

I’m a passionate web application developer and Ruby on Rails enthusiast. I love building stunning web applications and working with interesting people. I feel comfortable developing on the frontend as well as on the backend and I have a firm grasp of JavaScript and HTML5. In general I like being involved in many aspects of a product and to figure out perfect technical solutions for everybody’s satisfaction. Clemens is a DZone MVB and is not an employee of DZone and has posted 10 posts at DZone. You can read more from them at their website. View Full User Profile

Testing Tuesday Episode 18: How to Test Asynchronous JavaScript with Jasmine

08.14.2013
| 1771 views |
  • submit to reddit

This is the 18th Testing Tuesday episode. Every week we share our insights and opinions on the software testing space. Drop by every Tuesday to learn more! Last week we spied on JavaScript methods with Jasmine.

Testing Asynchronous JavaScript Operations

In the last two Testing Tuesday episodes we got familiar with Jasmine. If you haven’t already, watching Testing Tuesday #16 will make it easier to follow along with this episode.

JavaScript is the perfect language for asynchronous operations. Although they make our apps fast, elegant and responsive, they are also a challenge to test.

Jasmine provides two strategies for testing asynchronous operations:

  1. Waiting for certain events to occur until a timeout
  2. Mocking the JavaScript clock and simulating that time passes

In this screencast we cover both strategies and show you which one is appropriate for which situation.

Up Next Testing Tuesday: Testing Node.js Applications

So far we’ve used Jasmine only in the web browser. Next week we’ll show you how to test your Node.js applications with Jasmine. If you’ve got any questions or suggestions, please leave us a comment!


 

Published at DZone with permission of Clemens Helm, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)