Skip to content

Commit 284b130

Browse files
committed
Add a test for req param in beforeResponse
1 parent 9bcfff5 commit 284b130

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/integration/proxying/http-proxying.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,25 @@ nodeOnly(() => {
778778
expect(response).to.equal('all good');
779779
});
780780

781+
it("should be able to examine the request in beforeResponse", async () => {
782+
await remoteServer.forGet('/').thenCallback(() => ({
783+
status: 500,
784+
headers: {
785+
'UPPERCASE-HEADER': 'VALUE'
786+
}
787+
}));
788+
789+
await server.forGet(remoteServer.urlFor("/")).thenPassThrough({
790+
beforeResponse: (_res, req) => {
791+
expect(req.url).to.equal(remoteServer.urlFor('/'));
792+
return { status: 200, body: 'got correct req url' };
793+
}
794+
});
795+
796+
let response = await request.get(remoteServer.urlFor("/"));
797+
expect(response).to.equal('got correct req url');
798+
});
799+
781800
it("should be able to rewrite a response's status", async () => {
782801
await remoteServer.forGet('/').thenReply(404);
783802
await server.forGet(remoteServer.urlFor("/")).thenPassThrough({

0 commit comments

Comments
 (0)