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.