Otavio Macedo
Otavio Macedo

Reputation: 1572

How to block HTTP requests in a Jest test (except through a proxy)?

I am developing a Node.js application that makes HTTP(S) requests through a proxy, if configured to do so. So I'm writing Jest tests for this scenario, which is simple enough, using mockttp.

With this set-up, I can make sure that the proxy is intercepting some requests from my application, but I would also like to assert that all the requests that this application makes go through the proxy. If the application tries to bypass the proxy, it should fail.

How can I do that? In other words, I would like a way to simulate a (in-process) firewall that blocks all outgoing requests, except the ones coming from the proxy.

Upvotes: 0

Views: 33

Answers (0)

Related Questions