Book Image

Jasmine Cookbook

By : Munish Kumar
Book Image

Jasmine Cookbook

By: Munish Kumar

Overview of this book

Table of Contents (16 chapters)
Jasmine Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Introduction


A matcher is used to evaluate an assertion of an object. If the expected and actual values match, the assertion passes, or else, the assertion fails. Jasmine provides a rich set of built-in matchers to test JavaScript applications. To know more about Jasmine's built-in matchers, refer to the Applying different matchers to the Jasmine test recipe in Chapter 1, Getting Started with Jasmine Framework. In addition to the built-in matchers, Jasmine also provides various functions and enables you to create custom matchers to test JavaScript code. Custom matchers help to document the intent of the spec and can also help to remove code duplication across specs. In this chapter, we will investigate the need of such custom matchers and find out how to develop these in order to validate a specific test condition or scenario. In addition, you will learn how to test the scenarios that expect JavaScript exceptions to be thrown.