How to Mock Third-Party APIs in Supabase Edge Function Integration Tests?

My edge functions call third-party APIs like Stripe and Resend. For integration tests, I don’t want to hit real services—I need to mock or intercept these calls and control their responses. Supabase recommends using client.functions.invoke() for testing, but since edge functions run in isolated processes, I can’t mock dependencies at runtime. The best workaround I’ve found is to use dependency injection and an environment variable (e.g., ENV=test) to swap in fake SDKs, but this approach doesn’t allow me to tailor third-party responses for individual tests. How are others handling this scenario? I haven’t found Supabase docs that address mocking third-party APIs in integration tests, which seems like a fundamental need.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?