mirror of
https://github.com/proffesor-for-testing/agentic-qe.git
synced 2026-09-19 08:45:47 +08:00
b91627f282
Phase 1: Test Determinism - Create SeededRandom utility with Mulberry32 PRNG (src/utils/SeededRandom.ts) - Migrate 258+ Math.random() calls to SeededRandom across 65+ test files - Add timer test utilities (tests/helpers/timerTestUtils.ts) - Add jest.useFakeTimers() pattern to 13 test files Phase 2: Type Safety (63.5% reduction) - Reduce `any` types from ~1,800 to 656 - Add 50+ new interfaces across agents, core, mcp, cli modules - Fix all TypeScript errors (0 errors, build passes) - Replace Record<string, any> with Record<string, unknown> - Add proper type guards for hook methods (PostTaskData, TaskErrorData) Key improvements: - agents/: 105 → 0 any types (100% reduction) - mcp/: 226 → 102 any types (55% reduction) - cli/: 277 → 168 any types (39% reduction) - core/: 199 → 175 any types (12% reduction) Closes #149 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Test Fixtures for Phase 2
This directory contains test fixtures and mock implementations for Phase 2 integration tests.
Structure
fixtures/
├── phase2-mocks.ts # Shared mocks for all Phase 2 tests
├── test-code/ # Sample TypeScript files for evaluation tests
│ └── (created at test runtime)
└── validation/ # Sample files for validation criteria tests
└── (created at test runtime)
Usage
Mock Components
import {
MockSpan,
createMockVotingAgent,
createMockVote,
SAMPLE_CODE,
} from '../fixtures/phase2-mocks';
// Mock OpenTelemetry span
const span = new MockSpan('test-span');
span.setAttribute('key', 'value');
span.end();
// Mock voting agent
const agent = createMockVotingAgent('agent-1', 'test-generator', ['testing']);
// Mock vote
const vote = createMockVote('agent-1', 'task-1', 0.9, 0.95);
// Sample code for evaluation
const code = SAMPLE_CODE.simple;
Test Data
The phase2-mocks.ts module provides:
- MockSpan: Lightweight span implementation for testing without full OTEL
- Mock Voting Components: Agents, votes, tasks
- Mock LLM Responses: For semantic evaluation tests
- Sample Code: Various TypeScript code samples for evaluation
- Mock Databases: In-memory stores for testing
Best Practices
- Use Mocks Over Real Components: Prefer mocks for faster, isolated tests
- Clean Up After Tests: Reset mocks in
afterEach()hooks - Realistic Data: Mock data should reflect real-world scenarios
- Type Safety: All mocks are fully typed
Adding New Fixtures
- Add new mock to
phase2-mocks.ts - Export with proper TypeScript types
- Update this README with usage example
- Add JSDoc comments to the mock