Testing

Running Tests

Run tests
# Run all tests
pnpm test

# Watch mode
pnpm test -- --watch

# Coverage report
pnpm test:coverage

Test Structure

test/
├── metadata.test.ts    # Metadata generation tests
├── pumpfun.test.ts     # PDA derivation tests
└── api.test.ts         # API endpoint tests

Example Test

test/metadata.test.ts
// test/metadata.test.ts
import { describe, it, expect } from 'vitest';
import { generateMetadata } from '../src/lib/metadata';

describe('Metadata Generation', () => {
  it('generates valid token name', () => {
    const metadata = generateMetadata({ username: 'cryptofan' } as any);
    expect(metadata.name).toBe('WP_CRYPTOFAN');
    expect(metadata.name.length).toBeLessThanOrEqual(32);
  });

  it('handles special characters', () => {
    const metadata = generateMetadata({ username: 'crypto_fan!' } as any);
    expect(metadata.name).toBe('WP_CRYPTOFAN');
  });
});

Testing Without Real Launches

This lets you test detection and processing without creating real tokens.