Test Structure
Tests are organized in thetests/unit/ directory:
Running Tests
Test Configuration
Vitest is configured invitest.config.ts:
Key Configuration
- jsdom environment: Simulates a browser for client-side code
- Path alias
@/: Matches Next.js import paths - Globals enabled: No need to import
describe,it,expect
Writing Tests
Basic Tool Test
Test a simple tool transformation:Testing Actions
Test different actions for a tool:Testing Error Handling
Ensure tools handle invalid input gracefully:Testing with Secondary Input
For tools that accept two inputs (like diff):Test Categories
1. Engine Tests (engine.test.ts)
Covers core functionality for all 51 tools:2. Regression Tests (bugfixes.test.ts)
Prevents previously fixed bugs from returning:3. Fuzz Tests (fuzz.test.ts)
Tests parser robustness with adversarial inputs:Testing Best Practices
Common Testing Patterns
Continuous Integration
Tests run automatically on every push and pull request via GitHub Actions:Debugging Failed Tests
Performance Testing
Test that tools handle large inputs efficiently:Test Coverage Goals
- Tool coverage: All tools must have at least one test
- Action coverage: All actions must be tested
- Error coverage: All error paths must be tested
- Edge cases: Empty input, invalid input, boundary conditions
Troubleshooting
Tests Timeout
Import Errors
Ensure path alias is correct:jsdom Errors
Some browser APIs aren’t available in jsdom. Mock them:Next Steps
- Review deployment process
- Learn about adding new tools
- Study existing tests in
tests/unit/for examples