diff --git a/package.json b/package.json index caceab2..deab355 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "typescript-eslint-parser": "^21.0.2" }, "dependencies": { - "fake-xml-http-request": "^2.0.0", + "fake-xml-http-request": "kellyselden/FakeXMLHttpRequest#response", "route-recognizer": "^0.3.3", "whatwg-fetch": "^3.0.0" }, diff --git a/src/index.ts b/src/index.ts index 1909e56..ba36f9b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -113,7 +113,7 @@ function interceptor(ctx) { var uploadEvents = []; // properties to copy from the native xhr to fake xhr - var lifecycleProps = ['readyState', 'responseText', 'responseXML', 'responseURL', 'status', 'statusText']; + var lifecycleProps = ['readyState', 'responseText', 'response', 'responseXML', 'responseURL', 'status', 'statusText']; var xhr = fakeXHR._passthroughRequest = new ctx.pretender._nativeXMLHttpRequest(); xhr.open(fakeXHR.method, fakeXHR.url, fakeXHR.async, fakeXHR.username, fakeXHR.password); diff --git a/test/calling_test.js b/test/calling_test.js index d6529eb..f9cc9b2 100644 --- a/test/calling_test.js +++ b/test/calling_test.js @@ -168,6 +168,7 @@ describe('pretender invoking', function(config) { assert.equal(verb, 'GET'); assert.equal(path, '/some/path'); assert.equal(request.responseText, json); + assert.equal(request.response, json); assert.equal(request.status, '200'); done(); }; @@ -625,6 +626,7 @@ describe('pretender invoking', function(config) { assert.equal(verb, 'GET'); assert.equal(path, '/some/path'); assert.equal(request.responseText, json); + assert.equal(request.response, json); assert.equal(request.status, '200'); done(); }; diff --git a/test/passthrough_test.js b/test/passthrough_test.js index 67e9541..8a483a8 100644 --- a/test/passthrough_test.js +++ b/test/passthrough_test.js @@ -308,6 +308,7 @@ describe('passthrough requests', function(config) { this.open = function() {}; this.setRequestHeader = function() {}; this.responseText = ''; + this.response = ''; this.onload = true; this.send = { pretender: pretender, @@ -328,6 +329,11 @@ describe('passthrough requests', function(config) { event.target.responseText, 'responseText for real and fake xhr are both blank strings' ); + assert.equal( + xhr.response, + event.target.response, + 'response for real and fake xhr are both blank strings' + ); done(); }); diff --git a/yarn.lock b/yarn.lock index 3983a71..eacc8ef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1483,10 +1483,9 @@ extsprintf@^1.2.0: resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= -fake-xml-http-request@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/fake-xml-http-request/-/fake-xml-http-request-2.0.0.tgz#41a92f0ca539477700cb1dafd2df251d55dac8ff" - integrity sha512-UjNnynb6eLAB0lyh2PlTEkjRJORnNsVF1hbzU+PQv89/cyBV9GDRCy7JAcLQgeCLYT+3kaumWWZKEJvbaK74eQ== +fake-xml-http-request@kellyselden/FakeXMLHttpRequest#response: + version "2.0.1" + resolved "https://codeload.github.com/kellyselden/FakeXMLHttpRequest/tar.gz/a61474cc8cca4009f24f30fe42b3f6ba7ee4609e" fast-deep-equal@^2.0.1: version "2.0.1"