Testing with Jasmine

In many professions experts agree on a set of practices that are really good ideas, but few in the profession actively follow those conventions. In the field of web development, automated code testing is such an idea. It’s not that developers think doing so is a bad idea; it’s just that they rarely find the time to spend on it.

For many, the idea of automated code testing works very well for libraries with established APIs that rarely change, but in the context of peripheral application logic or, more especially, user interfaces, automated testing becomes a much more complex proposition. A variety of tools are now available that can be brought to bear in these different situations and make automatic testing truly straightforward.

The key tool introduced in this chapter is Jasmine, which is a system for writing and running test suites. Jasmine tests describe simple observable behaviors about a piece of code, and then run the code to see if the behavior occurs. As a fundamental description of how your code should behave, these types of tests can also be viewed as a specification of the problem and can lead you to think about your code in different ways.

Introducing Jasmine

Jasmine, one of the libraries originally designed for use in JavaScript, is a behavior-driven test suite. There are a variety of different ideas about how to design tests and how they should be integrated into projects. The key idea with behavior-driven development (BDD) testing ...

Get Smashing CoffeeScript 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.