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 tests using tracking properties


Jasmine provides a rich set of tracking properties, meaning every call to a spy (or spied function/object method) can be tracked and exposed using the calls property of Jasmine spies. We can also track the details of arguments that are passed to the spied function. In this recipe, you will learn how to a track a call(s) to spied function/object method using tracking properties.

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 different tracking properties of Jasmine spies.

"As a JavaScript developer, I want to apply different tracking properties so that I can implement a test condition successfully."

Let's consider some scenarios in the current context, that is, tracking properties of Jasmine spies should be applied for different test conditions:

  • Scenario-1: The .calls.any() property should return false if the spy is not called at all

  • ...