Testing Suite & Quality Assurance
Relevant source files
The following files were used as context for generating this wiki page:
The Testing Suite and Quality Assurance system in Claude-mem is designed to ensure the reliability of persistent memory operations, background service stability, and integration integrity across different environments (Claude Code and Cursor). It leverages the Bun test runner for high-performance execution of unit and integration tests, alongside automated diagnostic tools for issue reporting.
The suite focuses on validating core lifecycle events, including worker process management, context injection mechanisms, and adherence to logging standards. This ensures that memory capture and retrieval remain consistent even as the system evolves through its various architectural phases.
Test Infrastructure & Environment
The project utilizes bun:test as its primary testing framework. Testing involves heavy use of temporary directories and mock environments to simulate project structures and worker states without polluting the user's actual ~/.claude-mem directory.
Core Test Categories
| Category | Description | Key Files |
|---|---|---|
| Process Management | Validates worker spawning, PID management, and health check reliability. | tests/worker-spawn.test.ts |
| Context Integration | Ensures .mdc context files are correctly formatted and written for Cursor. | tests/cursor-context-update.test.ts |
| Observability Standards | Enforces the use of a unified logger over console.log in background services. | tests/logger-coverage.test.ts |
| Integration Reviews | Architectural assessments of hook behavior and platform-specific limitations. | cursor-hooks/REVIEW.md |
Sources: tests/worker-spawn.test.ts, tests/cursor-context-update.test.ts, tests/logger-coverage.test.ts
Worker Process Testing
Testing the WorkerService involves simulating the lifecycle of a background daemon. This includes port conflict resolution, PID file integrity, and health/readiness endpoint validation.
Health Check Workflow
Tests verify that the worker correctly reports its state through specific API contracts. This is critical for preventing "zombie ports" and ensuring the CLI can accurately report status.
The suite validates that /api/readiness returns 503 while the worker is initializing and 200 only when background tasks (like Database initialization) are complete.
Sources: tests/worker-spawn.test.ts:25-50, tests/worker-spawn.test.ts:180-210
Cursor Context Validation
A specific sub-suite targets the writeContextFile utility. It ensures that the Memory Definition Context (.mdc) files generated for the Cursor IDE follow the required frontmatter and markdown structure.
Validation Criteria
Tests enforce the following structure for the claude-mem-context.mdc file:
- Frontmatter: Must include
alwaysApply: trueand a specific description. - Atomic Writes: Ensures no
.tmpfiles are left behind during the update process. - Formatting: Validates multi-line context preservation and Unicode/Special character handling.
Observability & Quality Standards
The project maintains a strict "No Console Log" policy for background services. Since these services run in the background, standard output is often invisible to the user. A dedicated coverage test scans the src/ directory to enforce these standards.
Logger Coverage Statistics
The logger-coverage.test.ts analyzes:
- Import Patterns: Ensures
loggeris imported from the correct utility path. - Console Usage: Identifies
console.log/error/warncalls in high-priority service files. - Priority Mapping: Files in
services/worker/andservices/sqlite/are marked as high priority for logging.
Sources: tests/logger-coverage.test.ts:20-55, tests/logger-coverage.test.ts:110-135
Bug Reporting & Diagnostics
To maintain quality in production, the system includes an automated bug report generator. This tool collects system diagnostics and formats them for GitHub issue submission.
Diagnostic Collection Flow
The collector gathers:
- Versions: Claude-mem, Claude Code, and Platform details.
- Worker State: PID, Port, and running status.
- Logs: Extraction of the last 100+ lines from worker logs.
Conclusion
The Claude-mem Testing Suite provides a multi-layered defense against regressions. By combining automated process lifecycle tests, strict static analysis for logging, and a robust diagnostic collection system, the project ensures that the persistent memory system remains reliable across CLI and IDE integrations. The use of bun:test allows for rapid execution of these checks, maintaining a high-velocity development cycle while preserving technical accuracy.