-
Notifications
You must be signed in to change notification settings - Fork 27.5k
$httpBackend.passThrough() does not exist when running unit tests #2512
Comments
Same here. Using Angular v1.1.5. I would add that it looks that after specifying usage of e2e httpBackend it still tries to use ngMock one. |
Also having the same issues that @tadas-subonis is having, specifically that ngMockE2E version of $httpBackend isn't working. |
As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months. Please try the newest versions of Angular ( Thanks! |
Still not working with Angular 1.0.8. |
Can you give a running example of this not working? It may be the configuration of the application or karma? |
Hi Pete, I am experiencing the same issue . Here is my configuration... // Karma configuration module.exports = function (config) {
} And tests are .... describe('DataServiceSpec::', function () {
}); Error ... TypeError: Object # has no method 'passThrough' .... |
I am trying to test the rest end points. That is fire off http calls to real server and then verify the response. I wonder if Karma + Unit tests is the right approach to do so ... |
Same problem for me. I'm trying to test a directive where I mock the API request but I want the test to load the template. As |
@andreareginato it is much easier to preload templates into $templateCache for unit tests, as shown in https://github.com/vojtajina/ng-directive-testing - this way you don't need to fiddle with $http as all templates are already preloaded and it is not necessary to fetch them over XHR so no $http calls are happening. |
I finally made it work. Thanks @pkozlowski-opensource. For future rederences here some tips. karma.conf.js
directive.js
The thing that was not clear at first was how template modules are named and that the name must match with the URL of the directive. Now it works. Thanks. |
Going to close this one as a duplicate of #1434 where someone else is trying to use both unit and e2e mocks together. |
i don't think you can call passThrough() on unit test. I think it needs .run method and its only on e2e modules "ngMockE2E". |
When I try to run my unit tests with karma, I try to do:
so that the templates that angular tries to load and loaded properly however when running the unit test, it tells me the $httpBackend does not have a method of passThrough().
Right now I and loading the templates manually with jQuery and with the that the tests run fine.
I think this might be related to the issue detailed here : #2370
The text was updated successfully, but these errors were encountered: