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

Writing Jasmine specs using custom jQuery matchers


The jasmine-jquery plugin provides a rich set of custom matchers for jQuery framework. In this recipe, you will learn how to apply various custom matchers in different situations.

To understand this recipe, let's assume that you are developing an application using jQuery/JavaScript and you have to implement test code for various scenarios by applying different custom jQuery matchers.

"As a JavaScript developer I want to apply different custom jQuery matchers so that I can implement a test condition successfully."

Here are the different scenarios:

  • Scenario-1: The toContainText matcher should be applied successfully to find any text in an element

  • Scenario-2: The toHaveText matcher should be applied successfully to find text in an element

  • Scenario-3: The toHaveClass matcher should be applied successfully to detect the class of an element

  • Scenario-4: The toContainHtml matcher should be applied successfully to find an HTML element

  • Scenario-5: The...