-
Notifications
You must be signed in to change notification settings - Fork 27.4k
$httpBackend cannot mock binary blob responses at IE11 (InvalidStateError) #9669
Comments
This is not browser specific. And pretty much prevents your from mocking HTTP requests with And it's related to the issue in pull request #5415, but where that one is only concerned with using the |
@jurko-gospodnetic, I couldn't reprocude it just by #5415, although about |
The shortest way to reproduce the problem is to just use the following one-liner:
And here's a plnkr reproducing the error: http://plnkr.co/xenwdKodooTrYO7VG2P2 It shows that you can't treat the almost-blob API response object you get from ng-mock as a true blob, while you can do so with the original blob given to ng-mock in its expectation. It also shows how you can not do so with an almost-blob object you get by calling And if calling When calling
Chrome is not much better:
while FireFox seems to play a bit nicer and says:
and IE11 seems as uninformative as Chrome:
|
Although `copy()` does not need to (and never will) support all kinds of objects, there is a (not uncommon) usecase for supporting `Blob` objects: `ngMock`'s `$httpBackend` will return a copy of the response data (so that changes in one test won't affect others). Since returning `Blob` objects in response to HTTP requests and since `ngMocks`'s `$httpBackend` will use `copy()` to create a copy of that data, it is reasonable to support `Blob` objects. (I didn't run any benchmarks, but the additional check for the type of the copied element should have negligible impact, cmpared to the other stuff that `copy()` is going.) Fixes angular#9669
Although `copy()` does not need to (and never will) support all kinds of objects, there is a (not uncommon) usecase for supporting `Blob` objects: `ngMock`'s `$httpBackend` will return a copy of the response data (so that changes in one test won't affect others). Since returning `Blob` objects in response to HTTP requests is a valid usecase and since `ngMocks`'s `$httpBackend` will use `copy()` to create a copy of that data, it is reasonable to support `Blob` objects. (I didn't run any benchmarks, but the additional check for the type of the copied element should have negligible impact, compared to the other stuff that `copy()` is doing.) Fixes angular#9669
@jurko-gospodnetic, thx for the reproduction. I have submitted a fix in #14064. |
Although `copy()` does not need to (and never will) support all kinds of objects, there is a (not uncommon) usecase for supporting `Blob` objects: `ngMock`'s `$httpBackend` will return a copy of the response data (so that changes in one test won't affect others). Since returning `Blob` objects in response to HTTP requests is a valid usecase and since `ngMocks`'s `$httpBackend` will use `copy()` to create a copy of that data, it is reasonable to support `Blob` objects. (I didn't run any benchmarks, but the additional check for the type of the copied element should have negligible impact, compared to the other stuff that `copy()` is doing.) Fixes #9669 Closes #14064
Although `copy()` does not need to (and never will) support all kinds of objects, there is a (not uncommon) usecase for supporting `Blob` objects: `ngMock`'s `$httpBackend` will return a copy of the response data (so that changes in one test won't affect others). Since returning `Blob` objects in response to HTTP requests is a valid usecase and since `ngMocks`'s `$httpBackend` will use `copy()` to create a copy of that data, it is reasonable to support `Blob` objects. (I didn't run any benchmarks, but the additional check for the type of the copied element should have negligible impact, compared to the other stuff that `copy()` is doing.) Fixes #9669 Closes #14064
I found this issue running tests with karma at IE11 / Win8.1.
When i try to mock a blob response with
$httpBackend.expect
, i gotInvalidStateError
.I dig and found that this happens because of the
angular.copy
which clones fake response data.If i hack
angular.copy
with something like this the error stops.The text was updated successfully, but these errors were encountered: