---
description: Run tests with coverage across all three repos and produce a unified summary report
---

## Test Coverage Report — All Repos

Generate detailed test coverage reports for all three workspace repos and produce a unified summary.

---

### Prerequisites

- Python 3.12+ with `pytest` and `pytest-cov` installed
- Node.js 20+ with `pnpm` (common-plat) and `npm` (dashboards)
- `@vitest/coverage-v8` installed in each JS project (already in devDependencies)
- Common platform packages built: `cd ../learning_ai_common_plat && pnpm build`

---

### Step 1: Python tests — LysnrAI desktop + backend

// turbo
```bash
cd /Users/sd9235/code/mygh/learning_voice_ai_agent && python -m pytest tests/ backend/tests/ -v --tb=short --co -q 2>/dev/null | tail -5
```

Then run with coverage:

```bash
cd /Users/sd9235/code/mygh/learning_voice_ai_agent && python -m pytest tests/ backend/tests/ \
  --cov=src --cov=backend/src \
  --cov-report=term-missing \
  --cov-report=html:coverage/python-html \
  --cov-report=json:coverage/python-coverage.json \
  -v --tb=short 2>&1 | tail -80
```

> If `pytest-cov` is not installed, run: `pip install pytest-cov` first.

Cascade: Record the Python coverage summary (total lines, covered, missed, %).

---

### Step 2: Common Platform — all packages + services (Vitest)

// turbo
```bash
cd /Users/sd9235/code/mygh/learning_ai_common_plat && pnpm build 2>&1 | tail -5
```

Then run coverage:

```bash
cd /Users/sd9235/code/mygh/learning_ai_common_plat && pnpm -r exec vitest run --coverage 2>&1 | tail -100
```

If the recursive exec has issues, run per-service:

```bash
cd /Users/sd9235/code/mygh/learning_ai_common_plat && pnpm --filter @lysnrai/platform-service exec vitest run --coverage 2>&1 | tail -60
```

```bash
cd /Users/sd9235/code/mygh/learning_ai_common_plat && pnpm --filter @lysnrai/extraction-service exec vitest run --coverage 2>&1 | tail -60
```

Cascade: Record each package/service coverage summary (statements, branches, functions, lines %).

---

### Step 3: LysnrAI Dashboards (Vitest)

Run coverage for user dashboard (admin + tracker moved to `learning_ai_common_plat/dashboards/`):

```bash
cd /Users/sd9235/code/mygh/learning_voice_ai_agent/user-dashboard-web && npm run test:coverage 2>&1 | tail -60
```

```bash
cd /Users/sd9235/code/mygh/learning_ai_common_plat/dashboards/admin-web && npm run test:coverage 2>&1 | tail -60
```

```bash
cd /Users/sd9235/code/mygh/learning_ai_common_plat/dashboards/tracker-web && npm run test:coverage 2>&1 | tail -60
```

Cascade: Record each dashboard's coverage summary.

---

### Step 4: MindLyst Web (Vitest)

```bash
cd /Users/sd9235/code/mygh/learning_multimodal_memory_agents/mindlyst-native/web && npx vitest run --coverage 2>&1 | tail -60
```

Cascade: Record MindLyst web coverage summary.

---

### Step 5: MindLyst KMP Shared (Kotlin)

// turbo
```bash
cd /Users/sd9235/code/mygh/learning_multimodal_memory_agents/mindlyst-native && ./gradlew :shared:test 2>&1 | tail -30
```

> Note: KMP test coverage (Kover) is not yet configured. Record pass/fail + test count only.

---

### Step 6: Produce Unified Summary

Cascade: After all steps complete, produce a markdown summary table like this:

```
# Test Coverage Report — <date>

## Summary

| Repo / Component              | Framework | Tests | Pass | Fail | Stmts % | Branch % | Func % | Lines % |
|-------------------------------|-----------|-------|------|------|---------|----------|--------|---------|
| LysnrAI Python (desktop+BE)  | pytest    | ...   | ...  | ...  | ...     | ...      | ...    | ...     |
| Common Plat — platform-svc   | vitest    | ...   | ...  | ...  | ...     | ...      | ...    | ...     |
| Common Plat — extraction-svc | vitest    | ...   | ...  | ...  | ...     | ...      | ...    | ...     |
| LysnrAI Admin Dashboard      | vitest    | ...   | ...  | ...  | ...     | ...      | ...    | ...     |
| LysnrAI User Dashboard       | vitest    | ...   | ...  | ...  | ...     | ...      | ...    | ...     |
| LysnrAI Tracker Dashboard    | vitest    | ...   | ...  | ...  | ...     | ...      | ...    | ...     |
| MindLyst Web                  | vitest    | ...   | ...  | ...  | ...     | ...      | ...    | ...     |
| MindLyst KMP Shared           | kotlin    | ...   | ...  | ...  | N/A     | N/A      | N/A    | N/A     |

## Gaps & Recommendations

- List any components with <60% coverage
- List any components with 0 tests
- Suggest top files/modules to add tests for
```

Print the full summary to the chat.

Then ALWAYS save a historical snapshot in this parent folder:

- `docs/test-coverage/`

Filename format:

- `docs/test-coverage/TEST_COVERAGE_REPORT_<YYYY-MM-DD_HHMM_TZ>.md`

Also refresh the latest rolling report at:

- `docs/TEST_COVERAGE_REPORT.md`

---

### Step 7: Commit Coverage Reports

After writing both report files, commit them in the LysnrAI repo:

```bash
cd /Users/sd9235/code/mygh/learning_voice_ai_agent && git add docs/TEST_COVERAGE_REPORT.md docs/test-coverage/TEST_COVERAGE_REPORT_*.md && git commit -m "docs(coverage): add timestamped test coverage snapshot"
```

If there is nothing new to commit (same content/timestamp not created), report that no commit was created.

---

### Troubleshooting

| Problem | Fix |
|---------|-----|
| `pytest-cov` not found | `pip install pytest-cov` |
| `@vitest/coverage-v8` not found | `npm install -D @vitest/coverage-v8` (per project) |
| Common-plat coverage fails | Run `pnpm build` first, then retry |
| Dashboard coverage fails | Run `npm install` first in that dashboard |
| KMP tests fail to compile | Run `./gradlew :shared:compileKotlinJvm` first |
| Timeout on large test suites | Add `--reporter=verbose --pool=forks` to vitest |
