function stubXmlHttpWith(stubXhr) {
  XmlHttp.setGlobalFactory({
    createInstance() {
      return stubXhr;
    },
    getOptions() {
      return {};
    }
  });
}
Replace XmlHttp with a function that returns a stub XHR.
@param {!XhrLike.OrNative} stubXhr
@suppress {checkTypes} suppression added to enable type checking