Contents tagged with Spy

  • Spies and secret agents in javascript

    Hello everybody,

    Have you ever had a desire to become chief of secreat agent or spy? To be honest I never had such desire, but unwilignly I become chief of spies  and secret agents which I created in javascript. 

    To put simply during unit testing of javascript sometime is needed to mock calling to some functions with replacement of that function, and sometime there is a need to mock that function without it's replacement. 

    The first scenario is much easier to implement, while the second one required usage of apply function. 

    Take a look at the following picture:

    There are many js libraries which support both options ( with and without original function ). For example jasmine, … more