SpyOn to mock and Stub methods in angular unit test
Jasmine Spies help us to mock the execution of the Angular method.
It’s a easy way to check a method was called or not, without leaving Subject Under Test(SUT).
We can chain the spyOn method to get dummy return value using .and.returnvalue()
spyOn can call the original function using .and.callThrough().
Stub: a dummy piece of code that lets the test run, but you don't care what happens to it.
Mock: a dummy piece of code, that you VERIFY is called correctly as part of the test.
Spy: a dummy piece of code, that intercepts some calls to a real piece of code, allowing you to verify calls without replacing the entire original object.
EmoticonEmoticon