Testing Your Integration
This guide covers testing strategies for your Fanfare integration, including unit testing with mocks, integration testing with the staging environment, and end-to-end testing.Test Utilities
The Fanfare SDK provides test utilities for mocking the SDK in your tests.Core SDK Mock
Import the mock SDK factory from the test utilities:React Testing
For React components, use theMockFanfareProvider:
Testing Hooks
Test hooks using@testing-library/react:
Mock Data Fixtures
The SDK provides pre-built mock data for common entities:Available Mock Data
| Mock | Description |
|---|---|
mockQueue | Basic queue object |
mockQueueEnterResult | Result of entering a queue |
mockQueueStatus | Consumer’s queue status |
mockDraw | Basic draw object |
mockDrawStatus | Consumer’s draw status |
mockAuction | Basic auction object |
mockAuctionStatus | Consumer’s auction status |
mockWaitlistEntry | Waitlist entry |
mockTimedRelease | Timed release object |
mockExperience | Basic experience object |
Testing Event Handlers
Mock SDK events using theon method override:
Testing with Staging Environment
For integration tests, use the staging environment with test credentials:Staging Environment Setup
- Create a test organization in your Fanfare dashboard
- Generate test API keys (prefixed with
pk_test_) - Create test experiences for different scenarios
- Use the staging API endpoint:
https://api-staging.fanfare.io
Local Development Server
For local development with the full Fanfare stack:http://localhost:4802 (the consumer-app service).
Running the Local Stack
If you have access to the Fanfare development environment:- Admin API:
http://localhost:4800 - Admin Client:
http://localhost:4801 - Consumer API:
http://localhost:4802 - Beacon:
http://localhost:4803
Testing Different Scenarios
Queue Full Scenario
Authentication Required
Draw Lost Scenario
Auction Outbid Scenario
Network Error
End-to-End Testing
For E2E tests with Playwright or Cypress, use the staging environment:Playwright Example
Cypress Example
Test Data Management
Cleaning Up Test Data
After running tests, clean up test consumers and participations:Seeding Test Data
For integration tests, seed your test environment with data:Debugging Tests
Enable Debug Logging
Inspect SDK State
Network Request Inspection
In your browser’s DevTools, filter network requests by:api.fanfare.io(production)api-staging.fanfare.io(staging)localhost:4802(local development)
CI/CD Integration
GitHub Actions Example
Best Practices
1. Isolate Tests
Each test should start with a clean state:2. Mock External Dependencies
Always mock the SDK in unit tests to avoid network calls:3. Test Error States
Always test error handling:4. Use Realistic Timing
When testing time-based features (auctions, draws), use realistic but shortened timeframes:Next Steps
- Deployment - Production deployment checklist
- Next Steps - Where to go from here