Add XHR2 callback support
Hello,
I started using DexterJS for testing my ajax requests, and I really enjoy it so far.
However, I am using JQuery 2 and I found out that the only callback supported in master is onreadystatechange. Unfortunately, JQuery2 wants to use onload and friends.
I quickly tweaked my local copy's __DexterStateChange to invoke onload when switching the state to DONE. That gets me going for now, but it is by no mean a clean solution. Proper support for the new callbacks would be awesome if someone fins the time to do it.
:+1:
working on it, thanks
edit: For further reference: https://github.com/jquery/jquery/blob/master/src/ajax/xhr.js#L77-L110
Great! By the way, you might be interested to know it works fine with Backbone. Here are some gotchas that might find their way into the documentation by the way:
- I added
fakeXHR.requests = []to myQUnitmodule'ssetupto ensure my tests are independent. Otherwise, I might end up responding to requests from another testcase. IffakeXHR.requestsis considered as an internal api, maybe it would be useful to add an accessor method? - I use requireJS:
- I looked for fakeXHR for a while before I realized I had to add it as a requirement (
define(['fakeXHR', 'dexter', ...] function (fakeXHR, dexter, ...) {). - to have fakeXHR work fine it needs a
fakeXHR: "dexter"entry in the path configuration so it knows it is loaded from the same file as dexter. - apart from that, dexterjs plays surprinsingly well with requireJS.
- I looked for fakeXHR for a while before I realized I had to add it as a requirement (
@luanmuniz help \o/
working on it :)
@raphamorim wanna try this challenge too? :)