| name | testing |
| description | Test and verify AI orchestrator features using CLI runner, unit tests, and E2E tests.
ALWAYS use this skill when: implementing new features, fixing bugs, making changes to agents/orchestrator/TUI,
or when asked to verify something works. Claude MUST test changes before marking tasks complete.
|
| allowed-tools | Bash, Read, Write, Edit, Glob, Grep |
AI Orchestrator Testing
Core Principle
Never ship untested code. Before marking ANY task as complete, you MUST:
- Run relevant unit tests
- Use the CLI test runner to verify the feature works end-to-end
- Add or update tests to cover new functionality
- Ensure all tests pass
Testing Infrastructure
1. CLI Test Runner (Primary Tool for Verification)
The CLI lets you send messages and see responses WITHOUT the interactive TUI:
npm run cli -- "Create a PRD for user authentication"
npm run cli -- --verbose "Create a PRD for auth"
npm run cli -- --json "Test message"
npm run cli -- --timeout 60000 "Quick test"
Use this to verify:
- Intent classification works correctly
- Agents receive and process tasks
- Responses contain expected content
- The full message flow works end-to-end
2. Unit Tests (Vitest)
npm test
npm run test:watch
npm run test:coverage
Test locations:
packages/shared/src/__tests__/ - Type helpers, event creators
packages/orchestrator/src/__tests__/ - Router, classification
packages/agents/src/__tests__/ - Agent logic
3. E2E Integration Tests
npm run test:e2e
Location: packages/e2e/src/__tests__/
These tests start the backend, send real messages through queues, and verify responses.
Testing Workflow
When Implementing a New Feature
-
Before coding: Understand what tests exist
npm test
-
During development: Use CLI to verify changes
npm run cli -- --verbose "Test the new feature"
-
After implementation: Add tests
- Unit tests for new helper functions
- Integration tests for new message flows
- Update existing tests if behavior changed
-
Before completing: Run full test suite
npm test && npm run cli -- "Verify feature works"
When Fixing a Bug
- First: Write a failing test that reproduces the bug
- Then: Fix the bug
- Verify: Test passes and CLI shows correct behavior
- Finally: Ensure no regressions with
npm test
When Refactoring
- Before: Run
npm test to establish baseline
- After each change: Run tests to catch regressions
- Use CLI: Verify behavior hasn't changed
Test Requirements by Area
Shared Package (packages/shared/)
- All helper functions MUST have unit tests
- All type creators MUST have unit tests
- Test file:
src/__tests__/types.test.ts, src/__tests__/events.test.ts
Orchestrator (packages/orchestrator/)
- Intent classification MUST be tested
- Routing logic MUST be tested
- Add tests for new intent types
Agents (packages/agents/)
- Agent response formatting MUST be tested
- Error handling MUST be tested
TUI (packages/tui/)
- Use CLI runner for integration testing
- Component logic can have unit tests
Quality Gates
Before marking a task complete, verify:
Example: Verifying a Change
Say you modified the intent classification. Here's how to verify:
npm test
npm run cli -- --verbose "Create a PRD for authentication"
npm run cli -- --verbose "random gibberish text"
Adding New Tests
Unit Test Template
import { describe, it, expect } from 'vitest';
describe('MyFeature', () => {
it('does something correctly', () => {
const result = myFunction('input');
expect(result).toBe('expected');
});
it('handles edge cases', () => {
expect(() => myFunction(null)).toThrow();
});
});
E2E Test Template
import { describe, it, expect } from 'vitest';
import { sendTestMessage } from '@ai-orchestrator/test-utils';
describe('E2E: MyFeature', () => {
it('works end-to-end', async () => {
const response = await sendTestMessage('Test my feature', {
timeout: 60000,
verbose: true,
});
expect(response.status).toBe('complete');
expect(response.parts[0].content).toContain('expected text');
});
});
Remember
- Test early, test often - Don't wait until the end
- CLI is your friend - Use it liberally to verify changes
- Tests are documentation - They show how features should work
- Regressions are bugs - If a test breaks, fix it before continuing
- Coverage matters - New features need new tests
Additional References