Testing Approaches
You can test your bot in multiple ways:- Manual testing - Interact with your bot via WhatsApp
- Mock provider testing - Use the built-in test provider
- API testing - Test HTTP endpoints with tools like cURL or Postman
- Unit testing - Test individual flow components
Mock Provider Testing
BuilderBot includes aTestProvider for testing without WhatsApp:
Testing Flows
Basic Flow Test
Test that a flow responds correctly:Testing Capture
Test flows that capture user input:Testing State
Verify state is stored correctly:Testing HTTP Endpoints
Using cURL
Test your API endpoints:Test Script
Create a test script for automated API testing:Testing Media Files
Verify media sending works:Media Test Checklist
Image Tests
Image Tests
- Local PNG file
- Local JPG file
- URL image
- Large image (test timeout)
- Invalid path (error handling)
Video Tests
Video Tests
- Local MP4 file
- URL video
- Large video file
- Invalid format
Document Tests
Document Tests
- PDF file
- DOCX file
- XLSX file
- Invalid file type
Testing Error Handling
Test how your bot handles errors:Testing Validation
Performance Testing
Queue Load Test
Test queue behavior under load:Concurrent Users Test
Simulate multiple users via API:Test Checklist
Use this checklist before deploying:Flow Tests
- All keywords trigger correct flows
- Capture works and stores data
- State updates correctly
- fallBack repeats messages
- gotoFlow navigates correctly
- endFlow stops conversation
- Nested flows work
- Dynamic responses work
Media Tests
- Images send from local files
- Images send from URLs
- Videos send correctly
- Audio files send
- Documents send
- Large files timeout appropriately
API Tests
- Message endpoint works
- Flow trigger endpoint works
- Blacklist endpoints work
- State endpoints work
- Error responses are correct
- Authentication works (if implemented)
Integration Tests
- Database saves messages
- Database retrieves history
- Provider connects successfully
- QR code displays (for Baileys)
- Messages send to real WhatsApp
Performance Tests
- Queue handles multiple messages
- Concurrent users don’t conflict
- Memory usage is reasonable
- No memory leaks
- Logs are created correctly
Debugging Tips
Check logs
Check logs
View bot logs to debug issues:
Add debug logging
Add debug logging
Add console logs to track flow:
Test in isolation
Test in isolation
Test individual components separately:
Use test numbers
Use test numbers
Create dedicated test numbers:
Common Test Scenarios
Test User Registration
Test Error Recovery
Test Media Sending
Best Practices
Test after every change
Test after every change
Run tests after modifying flows:
Keep test data separate
Keep test data separate
Use dedicated test numbers and data:
Document test cases
Document test cases
Keep a list of test scenarios:
Automate repetitive tests
Automate repetitive tests
Create scripts for common tests:
Next Steps
- Review Creating Flows to improve your flows
- Check Queue System to optimize performance
- Explore State Management to test state handling