-
Notifications
You must be signed in to change notification settings - Fork 27.4k
lastCookieString.split error with httpBackend.flush() #11373
Comments
Yup, that's my fault. Fix is coming :) |
@jcdalton2201 can you confirm that you are indeed mocking out |
We do not have the $document mocked out. Our test was simply trying to test a $resource call. |
@jcdalton2201 can you post a minimal reproduce on plunker or something similar? |
I don't know if it's related or not, but the latest release has been breaking our tests as well and points to the cookies. Our version is 1.4.0-build.3869+sha.3b8163b. The errors:
Then I noticed that this section is missing from the latest release, which may be causing the problems: lines 69, 70:
lines 150-153:
lines 173-190:
|
@jcdalton2201 - I think the problem is that you have mocked out the var windowMock = {
navigator: {},
document: { cookie: '' }
}; See http://plnkr.co/edit/TQl5Qc?p=preview But I think that a sensible thing to do inside |
hmm..what if I get the same issue with |
I'm facing the same problem with Angular v1.3.15. The problem appeared when I deleted/re-installed all my bower dependencies (it worked with Angular v1.3.15 before). To fix the problem I used this small hack that mocks the
|
@Pyo25 - I'm facing exact problem like yours. Thanks for sharing the workaround. |
@Pyo25 @csreddy Happened to me as well. When I deleted my bower dependencies and reinstalled them, it did no more work (while it did before). My 1st thought was an implicit Angular upgrade as well, but I also tried to downgrade to various other v1.3.x versions, which didn't solve the issue. |
@shahata It looks like this:
I never use Angular cookies explicitly. What I do in ...
beforeEach(function(){
var dummyUserObj = {
id: 1,
username: 'Juri',
roles: [
{
role: 'admin',
functions: [ 'person.read', 'person.write']
}
]
};
$httpBackend
.when('GET', '/api/v1/users/current')
.respond(dummyUserObj);
service.getCurrent();
$httpBackend.flush();
});
... |
Here's my example, stack trace is similar to @juristr beforeEach(inject(function(_Bug_, $httpBackend) {
Bug = _Bug_;
httpBackend = $httpBackend;
currentUser = {
name: 'admin',
username: 'admin',
email: 'admin@email.com'
};
}));
// make sure no expectations were missed in your tests.
afterEach(function() {
httpBackend.verifyNoOutstandingExpectation();
httpBackend.verifyNoOutstandingRequest();
});
it('should get bug count', function() {
httpBackend.whenGET('/api/bugs/count').respond({
count: 100
});
Bug.count().then(function(response) {
expect(response.data.count).toBe(100);
});
httpBackend.flush();
});
|
Yes that was it 👍 (face palm moment). Thank you! |
Same for me, thanks @shahata ! |
Using v1.4.0-build.3918+sha.4588e62 my unit test are now having the following error.
The unit test is this
the line 263 coralates with the httpBackend.flush();
this unit test did work with 1.4.0-beta.0 and 1.3.15
The text was updated successfully, but these errors were encountered: