How To Stub External Services In Tests
Requests to external services during test runs can cause several issues:
- Tests failing intermittently due to connectivity issues.
- Dramatically slower test suites.
- Hitting API rate limits on 3rd party sites (e.g. Twitter).
- Service may not exist yet (only documentation for it).
- Service doesn’t have a sandbox or staging server.
When integrating with external services we want to make sure our test suite isn’t hitting any 3rd party services. Our tests should run in isolation.
So, here’s how to stub external services in tests.
Post a comment