April 2015
Intermediate to advanced
276 pages
5h 38m
English
In Jasmine, mocks are referred to as spies. Spies are used to mock a function/object method. A spy can stub any function and tracks calls and all its arguments. Jasmine provides a rich set of functions and properties to enable mocking. There are special matchers to interact with spies that are, toHaveBeenCalled and toHaveBeenCalledWith. In this recipe, you will learn how to mock a function using Jasmine's spyOn() function and special matchers.
To write the Jasmine tests using spies, let's assume that you are developing an application for <ABC> company, which provides solutions for the health care industry. Currently, there is a need to design a component that can get ...
Read now
Unlock full access