I am unit testing an Angular controller which calls a service to get json data. I'm using Jasmine spyOn to spy on my service's query method like this:
spyOn facilitiesService, 'query'
.and
.callFake (success, error) ->
deferred.promise.then success
deferred.promise.catch error
$promise: deferred.promise
I have defined a mock backend for running in the browser during development, that intercepts real REST calls, and uses $resource(path/to.json).query()
to return fake data. Whenever I have the mock backend enabled, browser testing works fine, but my unit tests fail with unexpected request when I do scope.$digest()
. How is the mock backend being called when I am spying on the method?
I would like this configuration to work with the mock backend specified so I can watch files and run unit tests before updating the application in the browser.
Aucun commentaire:
Enregistrer un commentaire