Skip to content

Commit

Permalink
fix(adapter-fetch): Add statusText to the response (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
josex2r authored Jun 5, 2020
1 parent 42004d2 commit 0d45953
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/adapters/custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class FetchAdapter extends Adapter {

return new Response(response.body, {
status: response.statusCode,
statusText: response.statusText,
headers: response.headers
});
};
Expand Down
1 change: 1 addition & 0 deletions packages/@pollyjs/adapter-fetch/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ export default class FetchAdapter extends Adapter {

const response = new Response(responseBody, {
status: statusCode,
statusText: pollyResponse.statusText,
headers: pollyResponse.headers
});

Expand Down
10 changes: 10 additions & 0 deletions packages/@pollyjs/adapter-fetch/tests/integration/adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ describe('Integration | Fetch Adapter', function() {
expect(nativeResponseBuffer.equals(replayedResponseBuffer)).to.equal(true);
});

it('should return status text', async function() {
const { server } = this.polly;

server.any(this.recordUrl()).intercept((_, res) => res.sendStatus(200));

const res = await this.fetch(new Request(this.recordUrl()));

expect(res.statusText).to.equal('OK');
});

describe('Request', function() {
it('should support Request objects', async function() {
const { server } = this.polly;
Expand Down

0 comments on commit 0d45953

Please sign in to comment.