Ask HN: How do you run integration tests involving third party HTTP services?

by labarilemon 9/27/2023, 10:21 AMwith 1 comments

Some approaches that come to mind:

- Convert the integration test to a "tighter" unit test which completely mocks the external service, thus effectively not firing any HTTP request

- Run a proxy/mock server intercepting all requests that responds with mock data, thus accepting and responding to HTTP requests. An example: https://mock-server.com

Most third party APIs do not provide a sandbox or a dry-run mode so this is a recurring topic.

I'm using Node.js so if you know of any node-specific tool, it'd be great!

by stop50on 9/27/2023, 10:35 AM

For my own tools i use python-responses for mocking the api responses and i have an seperate tool to check if my api calls still work.