Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(path-rewriter): improve coverage #751

Merged
merged 1 commit into from
Apr 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions test/e2e/path-rewriter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,26 @@ describe('E2E pathRewrite', () => {
expect(response.text).toBe('/API RESPONSE AFTER PATH REWRITE FUNCTION');
});
});

describe('Rewrite paths with function which return undefined', () => {
it('should proxy with requested path', async () => {
mockTargetServer
.get('/api/lorum/ipsum')
.thenReply(200, '/API RESPONSE AFTER PATH REWRITE FUNCTION');

const agent = request(
createApp(
createProxyMiddleware({
target: `http://localhost:${mockTargetServer.port}`,
pathRewrite(path, req) {
return undefined;
},
})
)
);

const response = await agent.get('/api/lorum/ipsum').expect(200);
expect(response.text).toBe('/API RESPONSE AFTER PATH REWRITE FUNCTION');
});
});
});