README
Research and recommendations for testing the Lattice CLI tool - a knowledge graph for markdown documentation.
Documents
| Document | Description |
|---|---|
| Testing Strategy | Comprehensive analysis covering architecture, patterns, NestJS utilities, and TDD workflow |
Key Takeaways
Testing Architecture
- Testing Layers approach: Unit (70%), Integration (25%), E2E (5%)
- Extract pure functions from services for mock-free unit testing
- Use NestJS
Test.createTestingModule()withoverrideProvider()instead of manual construction
Design Patterns for Testability
- Functional Core, Imperative Shell - Separate pure logic from I/O
- Ports and Adapters - Swappable dependencies (already used for embeddings)
- Command Query Separation - Methods do one thing
TDD Workflow
- TDD works best at unit level with pure functions (zero mock setup)
- Use NestJS testing module for service-level TDD
- Avoid the “mock setup tax” that kills TDD momentum
Quick Reference
What to Mock
- External APIs (Voyage AI, OpenAI)
- FalkorDB (unless using Testcontainers)
- Non-deterministic values (time, random)
What NOT to Mock
- Pure functions (extract and test directly)
- File I/O (use temp directories)
- Built-in mock providers (use MockEmbeddingProvider)
- Data structures and value objects
NestJS Testing Pattern
const module = await Test.createTestingModule({ imports: [SyncModule],}).overrideProvider(GraphService).useValue(mockGraphService).compile();Related Topics
- NestJS testing patterns with dependency injection
- Testcontainers for Docker-based integration testing
- Functional Core / Imperative Shell pattern
- Test-Driven Development workflow