What
Currently in my AngularJS project, I am attempting to monitor certain internal functions such as angular.module
and serviceProvider
.
How
Fortunately, I have managed to keep track of calls to angular.module
successfully.
var moduleCalls = spyOn(angular, 'module').and.callThrough();
moduleCalls.calls.count() //-> 6
However, my attempt to monitor angular.module(...).service
seems to show that it has never been called.
var serviceCalls = spyOn(angular.module('MyApp'), 'service').and.callThrough();
serviceCalls.calls.count() //-> 0
Similarly, I tried to monitor the usage of .provider
function.
var serviceCalls = spyOn(angular.module('MyApp'), 'provider').and.callThrough();
Why
Currently, this scenario is purely theoretical, as I aim to have the ability to track all user-generated components (such as modules, factories, services, directives, controllers, etc) as they are being created.
Moreover, I am curious if it is feasible to combine and.callThrough()
with and.callFake()
in order to record activities in an audit log.