Angular Testing: Testing Angular Services With Private Methods
lets say I got this kind of method on a service: this.search = function (term) { var deferred = $q.defer(); Restangular.all('search').getList(params)
Solution 1:
Answer: This turned to be a completely different problem. Vague karma/chai error messages led me in the wrong direction. The actual problem (if someone bumps into this issue again, which I believe they will..) is the bind
method. Turned out the phantomjs```` The headless browser we are running the tests with, Doesn't support
bind``` (as some other es5 methods, not all). Running the same tests with chrome/firefox works perfectly. Once I understood this was the problem, then solving was easy, just added an ES5-shim lib (that included bind) to the karma.conf.js configuration as an included file (or the way you add helpers in any other framework) and everything works perfectlly
Post a Comment for "Angular Testing: Testing Angular Services With Private Methods"