spy-proxy#
Object proxy helper to enable tracing of all function calls:
On a call to any function of the proxied object instance, the following is traced:
- The name of the function.
- How many times each function has been called.
- The arguments passed to the function.
- The return value of the function.
This is very helpful for asserting function calls in unit tests.
Example:
; let mock = SpyProxy; let result = mock; // Assert that the method was called (any number of times, any arguments, any return value).mock; // Assert that the method was called 1 time (regardless of arguments, regardless of return value).mock; // Assert that the method was called 1 time with one argument with value "John" (regardless of return value). mock; // Assert that the method was called 1 time with one argument with value "John" and that the returned value was "Hello John". mock;