-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing response based on responseType #175
Comments
Whelp, I got the tests to pass. I made it |
I don't know what your Hope this helps. Thanks for using Jasmine! Closing. |
@slackersoft I've also just come across this. The behaviour of jasmine does seem a bit strange.. if you set a In browservar req = new XMLHttpRequest;
req.responseType = 'json';
req.addEventListener('load', function(response) {
// This will come back with JSON response type.
console.log('Response type is: ' + response.currentTarget.responseType);
});
req.open('GET', 'https://api.github.com');
req.send(); With jasmine:var req = new XMLHttpRequest;
req.responseType = 'json';
req.addEventListener('load', function(response) {
// This will come back with EMPTY response type.
console.log('Response type is: ' + response.currentTarget.responseType);
});
req.open('GET', 'https://api.github.com');
req.send();
var request = jasmine.Ajax.requests.mostRecent();
request.respondWith({
status: 200,
responseText: JSON.stringify({ name: 'test' })
}); |
It looks like the original implementation of I would be happy to review a pull request to correctly respect the Reopening. Thanks for the additional info. |
I'll start by saying thanks for an awesome bit of software. I've been having a lot of fun using jasmine and jasmine-ajax.
I'm testing a polling engine that wraps XMLHttpRequest, and want to test that the responseType specified will return the correct type (i.e. if I specify type 'json', xhr.response should be an object). Here's what I'm trying to do:
I know this is flawed because after logging a few real xhrs it seems like my browser parses the json before xhr.response is available, and a realistic response would have an object in the response field. But since a real xhr parses a response based on responseType, I (probably naively) think that jasmine-ajax should somehow do the same. Thanks again.
The text was updated successfully, but these errors were encountered: