-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(ngMockE2E): ensure that mocked $httpBackend uses correct $browser #15601
Conversation
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
beforeEach(function() { | ||
callback = jasmine.createSpy('callback'); | ||
angular.module('ng').config(function($provide) { | ||
realHttpBackend = jasmine.createSpy('real $httpBackend'); | ||
$provide.value('$httpBackend', realHttpBackend); | ||
$provide.factory('$httpBackend', ['$browser', function($browser) { | ||
return realHttpBackend.and.callFake(function() { realHttpBackendBrowser = $browser; }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the following work as well (just trying to understand if I am missing something):
$provide.factory('$httpBackend', ['$browser', function($browser) {
realHttpBackendBrowser = $browser;
return realHttpBackend;
}]);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way we would be able to be sure that the factory had been called but not that the correct httpBackend service had been called, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't you explicitly checking about the correct service anyway?
(I am not saying you should change it, just wondering.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we check that the spy has been called so I guess you are right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But since I have a LGTM from you and Travis is green I am going to merge it as-is :-P
The fix from #13124 enabled ngMock and ngMockE2E to work together but
did it in a way that meant that the "real"
$httpBackend
service thatwas used in pass-through depended upon a different
$browser
serviceto the rest of the app.
This broke Protractor since it watches the
$browser
for outstandingrequests and the pass through requests were being tracked by the wrong
$browser
instance.Closes #15593
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
What is the current behavior? (You can also link to an open issue here)
What is the new behavior (if this is a feature change)?
Does this PR introduce a breaking change?
Please check if the PR fulfills these requirements
Other information: