In the previous two recipes, we looked at how we can spy on a function and track all the function's calls/arguments using the tracking properties of spies. Now, let's assume that there is no function that exists to spy on. There are several cases when one may need to replace the original method. For example, the original function/method takes a long time to execute, or it depends on another object(s) (or third party system) that is/are not available in the test environment. In this situation, it is beneficial to replace the original method with a fake/custom spy method for testing purposes. Jasmine provides a method called jasmine.createSpy
to create your own custom spy method. In this recipe, you will learn to develop a custom spy method. Also, you will learn how to track all the calls/arguments of the custom spy method.
Jasmine Cookbook
By :
Jasmine Cookbook
By:
Overview of this book
Table of Contents (16 chapters)
Jasmine Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Free Chapter
Getting Started with Jasmine Framework
Jasmine with TDD and BDD Processes
Customizing Matchers and Jasmine Functions
Designing Specs from Requirement
Jasmine Spies
Jasmine with AJAX, jQuery, and Fixtures
Code Coverage with Jasmine Tests
Jasmine with Other Tools
Developing JavaScript Apps Using Jasmine – a Real-time Scenario
Index
Customer Reviews