Standard Libraries
Use familiar testing tools for mocking
No Credit Usage
Test without consuming API credits
Overview
In v2, the built-in mock mode (mock=True, mock_handler, mock_responses) has been removed from the SDKs. Instead, use standard mocking libraries for your language to test ScrapeGraphAI integrations without making real API calls or consuming credits.
Python SDK Testing
Using unittest.mock
Using responses Library
Mock HTTP requests at the transport layer:
Using pytest Fixtures
Async Testing with aioresponses
JavaScript SDK Testing
Using Jest / Vitest
Using MSW (Mock Service Worker)
Mock at the network level for more realistic testing:Testing with cURL
Test API endpoints directly using cURL against a local mock server or staging environment:SDK Comparison
Best Practices
- Mock at the client method level for unit tests (fastest, simplest)
- Mock at the HTTP level for integration tests (validates request/response shapes)
- Use fixtures to share mock configurations across tests
- Keep mock responses realistic - match the actual API response structure
- Test both success and error scenarios
Support
GitHub Issues
Report bugs or request features
Documentation
Python SDK documentation