Skip to content

Commit

Permalink
test(proxy): avoid consuming body in interceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jun 28, 2023
1 parent 8783ab6 commit b960a74
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,23 +399,23 @@ describe("", () => {
});

it("allows to get the actual response", async () => {
let proxyResponse;
let headers;

app.use(
"/",
eventHandler((event) => {
return proxyRequest(event, url + "/debug", {
fetch,
async onResponse(_event, response) {
proxyResponse = await response.json();
onResponse(_event, response) {
headers = Object.fromEntries(response.headers.entries());
},
});
})
);

await request.get("/");

expect(proxyResponse).toEqual({ foo: "bar" });
expect(headers["content-type"]).toEqual("application/json");
});
});
});

0 comments on commit b960a74

Please sign in to comment.