Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Testing Tuesday Episode #16: Javascript Testing with Jasmine

DZone's Guide to

Testing Tuesday Episode #16: Javascript Testing with Jasmine

· Web Dev Zone ·
Free Resource

Learn how error monitoring with Sentry closes the gap between the product team and your customers. With Sentry, you can focus on what you do best: building and scaling software that makes your users’ lives better.

 

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:

What’s the best way to boost the efficiency of your product team and ship with confidence? Check out this ebook to learn how Sentry's real-time error monitoring helps developers stay in their workflow to fix bugs before the user even knows there’s a problem.

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}