Skip to main content
This guide covers testing strategies, patterns, and best practices for the @elizaos/plugin-twitter package.

Test Environment Setup

Prerequisites

  1. Test Twitter Account
    • Create a dedicated test account
    • Apply for developer access
    • Create test app with read/write permissions
  2. Test Credentials
    • Generate OAuth 1.0a credentials for testing
    • Store in .env.test file
    • Never use production credentials for tests
  3. Environment Configuration

Unit Testing

Testing Client Base

Testing Post Client

Testing Interaction Client

Integration Testing

Testing Twitter Service

Testing End-to-End Flow

Performance Testing

Rate Limit Testing

Memory Usage Testing

Mock Utilities

Twitter API Mocks

Test Helpers

Test Configuration

vitest.config.ts

Test Setup

Debugging Tests

Enable Debug Logging

Test Reporters

CI/CD Integration

GitHub Actions Workflow

Best Practices

  1. Always Use Dry Run
    • Set TWITTER_DRY_RUN=true for all tests
    • Never post real tweets in tests
    • Mock API responses
  2. Test Rate Limiting
    • Simulate 429 errors
    • Test retry logic
    • Verify queue behavior
  3. Mock External Calls
    • Mock Twitter API
    • Mock LLM generation
    • Control test data
  4. Test Edge Cases
    • Empty timelines
    • Malformed tweets
    • Network failures
    • Auth errors
  5. Performance Testing
    • Monitor memory usage
    • Test with large datasets
    • Measure processing times