Skip to main content

Test Coverage

Detailed breakdown of test coverage across all components of Clear AI v2.

Summary

MetricValue
Total Tests960+
Overall Pass Rate97%
Code Coverage93.2%
Test Files69
Test Suites~45

Coverage by Layer

Shared Library (19 Modules)

724 Unit Tests + 100+ Integration Tests

ModuleUnit TestsIntegration TestsPass Rate
Conversational AI
- Response System258100%
- Intent Classification185100%
- Confidence Scoring153100%
- Progress Tracking202100%
- Conversation Utilities142100%
Context & Memory
- Context Management4512100%
- Compression355100%
- Memory Systems321592%
Workflows
- Workflow Graphs188100%
- Checkpointing172100%
Infrastructure
- Token Management285100%
- LLM Providers151292%
- Configuration183100%
- Observability125100%
Foundation
- Types50-100%
- Validation885100%
- Utilities1858100%
- Tools (MCP)44-100%
- API (REST)52-100%
Subtotal724100+98%

Agent System (5 Agents)

78 Unit Tests + 102 Integration Tests

AgentUnit TestsIntegration TestsPass Rate
Planner1824100%
Executor2115100%
Analyzer1812100%
Summarizer811100%
Orchestrator1316100%
System E2E-20100%
Subtotal78102100%

GraphQL API

62 Integration Tests

Test SuiteTestsPassingPass Rate
Server Integration121192%
Query Resolvers1818100%
Mutation Resolvers1717100%
Subscription Resolvers151493%
Subtotal626097%

Code Coverage Report

Overall Coverage

File                  | % Stmts | % Branch | % Funcs | % Lines |
----------------------|---------|----------|---------|---------|
All files | 93.2 | 84.7 | 95.8 | 93.2 |

By Component

Agents:

agents/
planner.ts | 95.2 | 87.5 | 100 | 95.2 |
executor.ts | 93.8 | 85.0 | 100 | 93.8 |
analyzer.ts | 91.5 | 82.3 | 95.5 | 91.5 |
summarizer.ts | 89.7 | 78.9 | 91.7 | 89.7 |
orchestrator.ts | 96.3 | 90.1 | 100 | 96.3 |

GraphQL:

graphql/
server.ts | 88.5 | 75.0 | 91.7 | 88.5 |
resolvers.ts | 92.1 | 83.3 | 94.4 | 92.1 |
schema.ts | 100 | 100 | 100 | 100 |

Shared Library:

shared/
llm/provider.ts | 92.1 | 85.7 | 94.4 | 92.1 |
memory/manager.ts | 88.5 | 76.4 | 88.9 | 88.5 |
context/manager.ts | 94.7 | 88.2 | 96.3 | 94.7 |
workflow/executor.ts| 91.3 | 82.1 | 93.5 | 91.3 |

Tools:

tools/
shipments.ts | 96.8 | 91.7 | 100 | 96.8 |
facilities.ts | 95.2 | 89.3 | 97.8 | 95.2 |
contaminants.ts | 94.1 | 87.5 | 96.5 | 94.1 |
inspections.ts | 93.7 | 86.2 | 95.8 | 93.7 |

Test Execution Times

Unit Tests

Component                    Tests    Time
─────────────────────────────────────────
Shared Library (724 tests) 724 8.5s
Agent Unit Tests (78 tests) 78 2.1s
─────────────────────────────────────────
Total Unit Tests 802 10.6s

Integration Tests

Component                       Tests    Time
──────────────────────────────────────────────
Agent Integration Tests 102 95.2s
GraphQL Tests 62 2.2s
LLM Provider Tests 12 18.4s
Memory System Tests 15 22.1s
Other Integration Tests 13 15.8s
──────────────────────────────────────────────
Total Integration Tests 160+ 153.7s (2.6 min)

Complete Test Suite

Total Time: ~164s (2.7 minutes)

Test Quality Metrics

Reliability

  • Flaky Test Rate: < 1% (deterministic)
  • False Positive Rate: ~2% (2 GraphQL test mock issues)
  • Test Stability: 99%+ (consistent results)

Coverage Gaps

Areas with Lower Coverage (< 90%):

  1. Memory Systems (88.5%)

    • Reason: Requires Neo4j/Pinecone services
    • Mitigation: Mock-based tests, integration tests optional
  2. Observability (85-90%)

    • Reason: Requires Langfuse service
    • Mitigation: Integration tests skipped when service unavailable
  3. Subscription Edge Cases (93%)

    • Reason: WebSocket timing complexity
    • Mitigation: Known issues documented, functional code verified

High-Value Coverage

Critical Paths with 100% Coverage:

  • ✅ All agent business logic
  • ✅ Query planning and validation
  • ✅ Plan execution and dependency resolution
  • ✅ Tool parameter resolution
  • ✅ Error handling and retries
  • ✅ GraphQL query and mutation resolvers

Test Maintenance

Adding New Tests

# Create test file
touch src/tests/my-module/my-feature.test.ts

# Write test
# Run to verify
yarn test src/tests/my-module/my-feature.test.ts

# Run all tests
yarn test

Updating Existing Tests

# Make changes
vim src/tests/agents/planner.test.ts

# Run affected tests
yarn test planner

# Verify coverage maintained
yarn test:coverage

Test Data Fixtures

Located in src/tests/fixtures/:

  • waste-data.ts - Mock waste management data
  • memory-mocks.ts - Memory system mocks
  • shared-test-data.ts - Shared test utilities

Continuous Integration

GitHub Actions

on: [push, pull_request]

jobs:
unit-tests:
# Fast feedback (~15s)
run: yarn test

integration-tests:
# Thorough validation (~3 min)
run: yarn test:integration

graphql-tests:
# API layer validation (~2s)
run: npx jest src/tests/graphql

Coverage Reporting

# Generate coverage report
yarn test:coverage

# View in browser
open coverage/lcov-report/index.html

# CI uploads to Codecov (if configured)

Coverage Goals

Current

  • Unit Tests: 93.2% coverage
  • Integration Tests: 97% pass rate
  • Overall: 960+ tests

Target

  • Unit Tests: 95% coverage
  • Integration Tests: 99% pass rate
  • Agent Tester: 200+ scenarios