Testing Guide
Best practices for testing your Vera API integration before going to production.
Use your API key in development to test against the live API. All enrichment jobs count against your rate limits, so test thoughtfully.
Testing Error Conditions
Verify your integration handles errors correctly:
# Invalid API key → 401
curl -X POST https://api.veraenrich.com/enrich \
-H "Authorization: Bearer invalid_key" \
-H "Content-Type: application/json" \
-d '{"domain": "stripe.com"}'
# Missing required field → 400
curl -X POST https://api.veraenrich.com/enrich \
-H "Authorization: Bearer $VERA_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
# Invalid domain → 400
curl -X POST https://api.veraenrich.com/enrich \
-H "Authorization: Bearer $VERA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"domain": "not-a-valid-domain"}'
# Non-existent job → 404
curl https://api.veraenrich.com/enrich/00000000-0000-0000-0000-000000000000 \
-H "Authorization: Bearer $VERA_API_KEY"
Mocking the API
For unit tests, mock the Vera API instead of making real requests:
- JavaScript (Jest)
- Python (pytest)
const mockCompletedJob = {
status: 'completed',
domain: 'stripe.com',
data: {
name: 'Stripe',
domain: 'stripe.com',
industry: 'Financial Technology',
employeeCount: '8000-10000',
confidence: 92,
sources: ['website', 'linkedin', 'ai']
}
};
jest.mock('./vera-client');
describe('Lead Enrichment', () => {
it('should enrich a lead with company data', async () => {
const veraClient = require('./vera-client');
veraClient.enrich.mockResolvedValue({ jobId: 'test-123' });
veraClient.getJob.mockResolvedValue(mockCompletedJob);
const lead = { email: 'john@stripe.com', name: 'John Doe' };
const enrichedLead = await enrichLead(lead);
expect(enrichedLead.company.name).toBe('Stripe');
expect(enrichedLead.company.industry).toBe('Financial Technology');
});
});
from unittest.mock import patch
MOCK_COMPLETED_JOB = {
'status': 'completed',
'domain': 'stripe.com',
'data': {
'name': 'Stripe',
'industry': 'Financial Technology',
'employeeCount': '8000-10000',
'confidence': 92
}
}
@patch('requests.post')
@patch('requests.get')
def test_enrich_lead(mock_get, mock_post):
mock_post.return_value.json.return_value = {'jobId': 'test-123'}
mock_get.return_value.json.return_value = MOCK_COMPLETED_JOB
lead = {'email': 'john@stripe.com', 'name': 'John Doe'}
enriched = enrich_lead(lead)
assert enriched['company']['name'] == 'Stripe'
Pre-Production Checklist
| Test Case | Expected Result |
|---|---|
| Valid enrichment request | Returns jobId with 202 status |
| Poll for completed job | Returns company data with confidence score |
| Invalid API key | Returns 401 with AUTHENTICATION_FAILED |
| Missing required field | Returns 400 with VALIDATION_ERROR |
| Rate limit exceeded | Returns 429 with Retry-After header |
| Invalid job ID | Returns 404 with JOB_NOT_FOUND |
| Bulk with mixed domains | Processes valid, reports invalid |
| Network timeout | Your retry logic handles gracefully |
Common Issues
| Issue | Cause | Solution |
|---|---|---|
| 401 errors | Invalid or missing API key | Check Authorization header format |
| Empty company data | Domain has limited online presence | Check confidence score, handle nulls |
| Slow responses | Large company or complex enrichment | Implement proper polling with timeout |
| Duplicate jobs | Same domain submitted multiple times | Cache job IDs, check before submitting |