Jasmine Spyon
The first methodology can be implemented by using spyon and the second methodology can be implemented using createspy.
Jasmine spyon. Jasmine has test double functions called spies. There are two ways to create a spy in jasmine. A spy only exists in the describe or it block in which it is defined and will be removed after each spec. Jasmine spy is another functionality which does the exact same as its name specifies.
Returns 42 documentation generated by jsdoc 363 on thu jul 23 2020 163745 gmt 0700 pacific daylight time. Spyon can only be used when the method already exists on the object whereas jasminecreatespy will return a brand new function. Spyonsomeobj funcwithargs1 2 3andreturnvalue42. There are special matchers for interacting with spies.
There are two types of spying technology available in jasmine. It will allow you to spy on your application function calls. It replaces the spied method with a stub and does not actually execute the real method. In jasmine mocks are referred to as spies.
Spyon takes two parameters. A spy can stub any function and tracks calls to it and all arguments.