Google Groups

Re: [AngularJS] Re: Mock dep to test service error

Mike Spainhower Mar 19, 2013 3:14 PM
Posted in group: Angular and AngularJS discussion
Thank you for posting this for others to find later, I forgot to come back and close this out :-)

On Tue, Mar 19, 2013 at 1:32 PM, Christian Dannie Storgaard <> wrote:
I believe the trick is to return null from the module ($provide) function - as it seems you've discovered as well ;)

So, for others stumbling on to this thread, this won't work:
module ($provide) ->
      $provide.value '$window', mock
      $provide.value '$q', q

this will:
module ($provide) ->
      $provide.value '$window', mock
      $provide.value '$q', q

On Wednesday, 20 February 2013 13:00:16 UTC+2, Mike Spainhower wrote:
Is the documentation at still valid?  I am trying to mock $window in the same fashion for a service's unit test, but get the following error when $provide.value('$window', mock) is present

Error: Argument 'fn' is not a function, got Object
            at assertArg (/home/spainhower/apps/frontend/angular-piwik/vendor/angular.js:975)
            at assertArgFn (/home/spainhower/apps/frontend/angular-piwik/vendor/angular.js:986)
            at annotate (/home/spainhower/apps/frontend/angular-piwik/vendor/angular.js:2306)
            at invoke (/home/spainhower/apps/frontend/angular-piwik/vendor/angular.js:2789)
            at /home/spainhower/apps/frontend/angular-piwik/vendor/angular.js:2662


You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit
To unsubscribe from this group and all its topics, send an email to

To post to this group, send email to
Visit this group at
For more options, visit