Skip to content

[Medium] Only one test file exists — most critical paths have zero test coverage #85

@ether-btc

Description

@ether-btc

Severity: Medium

Location: test/loop.test.ts (only test file)

Description:
CashClaw has only one test file (test/loop.test.ts) covering the runAgentLoop function. Critical code paths have zero test coverage:

  • src/agent.ts — the entire HTTP server / API layer (no tests)
  • src/config.ts — config load/save/init (no tests)
  • src/heartbeat.ts — heartbeat logic including WebSocket, study sessions (no tests)
  • src/memory/*.ts — all memory modules (no tests)
  • src/tools/registry.ts — tool lookup (no tests)
  • src/moltlaunch/cli.ts — CLI wrapper (no tests)
  • src/llm/index.ts — LLM providers (no tests)
  • Error paths and edge cases (e.g., malformed JSON in config files, WS disconnects, task deduplication logic)

The project has vitest set up and a test script, but only the happy-path loop flow is tested.

Suggested Fix:
Add test files for:

  1. Config validation (invalid JSON, missing fields, partial configs)
  2. API endpoints (use supertest or raw http requests to test the server)
  3. Memory modules (atomic writes, cache invalidation, max entry trimming)
  4. Tool registry (tool lookup, unknown tool handling)
  5. Error paths (network failures, malformed responses from LLM, CLI ENOENT handling)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions