Monkey patch XMLHttpRequest with request counter
One reason we use sleep
in a few places in our rspec feature tests is because we can't wait_for_xhr
as vanilla XMLHttpRequest
can't count the active requests.
Previously I proposed an injection solution that let the test author manually patch the object, this added too much complexity as you had to patch_wait_for_xhr
anytime the page changed and then wait_for_xhr
when you need to.
This was originally to solve DropLab's use of XMLHttpRequest
, but we decided that counter is useful in the production version of DropLab anyway.
I think we can do the same for GitLab, add a javascripts/extensions/xml_http_request
patch for production that adds counters. If people didn't want to do that, maybe we can use webpack to generate a test-specific bundle that includes the patch for rspec tests?