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

Using jasmine.any and jasmine.objectContaining


In this recipe, we will design Jasmine tests using jasmine.any and jasmine.objectContaining.

The jasmine.any function takes a constructor/class as an expected value. It returns true if the constructor matches the constructor of the actual value. The jasmine.objectContaining compares objects with actual key/value pairs.

To understand this recipe, let's assume that you are developing a JavaScript application and you have to implement test code for various scenarios by applying jasmine.any and jasmine.objectContaining.

"As a JavaScript developer I want to develop Jasmine tests using jasmine.any and jasmine.objectContaining so that I can implement a test condition successfully."

Let's consider some scenarios in the current context, that is, jasmine.any and jasmine.objectContaining should be applied for different test conditions:

  • Scenario-1: The jasmine.any function should be applied successfully for comparing types of arguments.

  • Scenario-2: The jasmine...