Over a million developers have joined DZone.

Testing Tuesday Episode #16: Javascript Testing with Jasmine

· Web Dev Zone

Start coding today to experience the powerful engine that drives data application’s development, brought to you in partnership with Qlik.


This is the 16th Testing Tuesday episode. Every week we will share our insights and opinions on the software testing space. Drop by every Tuesday to learn more! Last week we showed you how to set up Cucumber with standalone Ruby applications and Rails web applications.

How to test Javascript with Jasmine

We already tested Javascript in previous episodes with Selenium and Cucumber. Both frameworks perform integration tests by running a browser, interacting with the user interface and checking the outcome. Like the users of our web applications, these tests didn’t care if certain functionality was implemented in Javascript, in our backend application or at the database level.

This kind of testing is totally sufficient if you only implement occasional click-handlers and AJAX calls in Javascript. But once you start writing your own components like JQuery plugins or data models, you probably want to test them at a finer-grained level. That’s what Jasmine is for.

Jasmine is a unit testing framework for Javascript. Its syntax encourages behavior-driven development and looks similar to RSpec’s syntax. To get started with Jasmine we only need to download the latest version of the Jasmine Standalone.

In this screencast we’ll walk you through creating a little application using behavior-driven development with Jasmine.

Up Next Testing Tuesday: All About Jasmine Spies.

Next week we’ll show you how to use Jasmine spies to check if methods on Javascript objects got called or not. If you’ve got any questions or suggestions, please leave us a comment!

Further info:

Create data driven applications in Qlik’s free and easy to use coding environment, brought to you in partnership with Qlik.


Published at DZone with permission of Clemens Helm, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}