How to best mock external API calls from Edge Functions during unit tests?

I am trying to mock an external api call to Hubspot in one of my edge functions, is this possible and what would be the best way to do it? I am using TS. I am using the HttpClients fetch to make the call.
3 Replies
ihm40
ihm405w ago
i don't know off the top of my head but maybe you can see if an npm module might help. What would you like to see? As in what does you testing/mocking ideally look like?
21 Cabbage
21 CabbageOP5w ago
I think I had a lapse of judgement, I ended up just breaking down the functionality within the edge function and writing tests for that logic which was probably the better approach to begin with.
ihm40
ihm405w ago
yeah that makes sense

Did you find this page helpful?