-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(ngMockE2E): allow $httpBackend.passThrough() to work when ngMock is loaded #13124
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
@googlebot I signed it! |
…is loaded Allow $httpBackend.passThrough() to work normally when ngMock is loaded concurrently with ngMockE2E, as is typically the case when writing tests with angular.mock.module() Fixes angular#1434
dcd37fe
to
92d8971
Compare
CLAs look good, thanks! |
What does one need to do to get a PR merged around here? |
Hi @Narretz, For me, the passthrough is useful when I have a test fixture that cannot be easily inlined into JavaScript (such as an image). I have an Angular directive and service that convert (user-provided) images into clickable thumbnails when they exceed a certain size. The most straightforward (and realistic) way to test this functionality is to provide a real image as my test fixture, and actually let the browser make a real HTTP request to grab the image. I suspect that there are also many other integration testing scenarios that could benefit from the semantics of a unit test, with occasional "real" HTTP requests thrown in. This workflow is difficult to achieve in practice, because the Hope this helps! I realize that my proposed solution isn't the most ideal, but it doesn't seem like it would make things worse for anybody. |
LGTM - merging |
This change had a bad side effect on protractor. Protractor no longer waits for pass through requests. |
I'm not an expert on Angular internals, but this change smells bad because it causes 2 instances of $httpBackend and dependent services (e.g. $browser) to exist and that violates the implied "all services are singletons" policy of Angular. This is bound to cause people issues (e.g. protractor). |
@mike-bresnahan - can you create a new issue for this. I see that the problem is that calling |
Petebacondarwin, yes that is my understanding of the root cause as well and I have created a new issue for it. |
The fix from angular#13124 enabled ngMock and ngMockE2E to work together but did it in a way that meant that the "real" `$httpBackend` service that was used in pass-through depended upon a different `$browser` service to the rest of the app. This broke Protractor since it watches the `$browser` for outstanding requests and the pass through requests were being tracked by the wrong `$browser` instance. Closes angular#15593
The fix from #13124 enabled ngMock and ngMockE2E to work together but did it in a way that meant that the "real" `$httpBackend` service that was used in pass-through depended upon a different `$browser` service to the rest of the app. This broke Protractor since it watches the `$browser` for outstanding requests and the pass through requests were being tracked by the wrong `$browser` instance. Closes #15593
The fix from angular#13124 enabled ngMock and ngMockE2E to work together but did it in a way that meant that the "real" `$httpBackend` service that was used in pass-through depended upon a different `$browser` service to the rest of the app. This broke Protractor since it watches the `$browser` for outstanding requests and the pass through requests were being tracked by the wrong `$browser` instance. Closes angular#15593
Allow $httpBackend.passThrough() to work normally when
ngMock
is loaded concurrently withngMockE2E
. This also allows one to useangular.mock.module()
to write tests that depend onngMockE2E
, asmodule()
always adds a dependency onngMock
.Fixes #1434