Q&A
How do you handle API rate limiting in automated test suites?
Ajitesh MohantaAmbassador
4w ago 856 0
Our test suite hits a third-party API (Stripe sandbox) and we occasionally get 429s in CI, causing random test failures.
Approaches I've considered:
- Mock Stripe entirely (loses confidence we're calling the real API correctly)
- Throttle requests in tests with `time.sleep` (slow)
- Use the Stripe test clock and mock server (`stripe-mock`) — haven't tried this yet
- Run Stripe-dependent tests in a separate slow suite
How do you handle rate limits from external APIs in your test suites, especially in CI where tests run concurrently?