# Test Diagnostics

> Profile all test files to find slow, hanging, or failing tests. Use when tests seem slow or when vitest hangs. Use when this capability is needed.

- Skill: `tomevault-io/test-diagnostics` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/test-diagnostics`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/test-diagnostics/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/test-diagnostics

---


# Test Diagnostics

Profile every test file in the monorepo individually to find slow, hanging, or failing tests.

## Quick run

Run the diagnostics script:

```bash
.claude/skills/test-diagnostics/run-diagnostics.sh
```

Options:
- `--timeout 30` — Kill tests after N seconds (default: 30)
- `--slow-threshold 5` — Report tests taking > N seconds as SLOW (default: 5)
- `--dir ./test/integration` — Only test files under a specific directory

## After running

1. Review the summary output
2. For any **HANG** tests, read the test file and look for:
   - Missing `afterAll` cleanup or open connections
   - Servers or background processes that aren't shut down
   - Infinite loops or unresolved promises
   - File watchers that aren't cleaned up
3. For any **FAIL** tests, run them individually with verbose output:
   ```bash
   bunx --bun vitest run <path> 2>&1
   ```
4. For **SLOW** tests (>5s), check if they can be optimized:
   - Are they spawning CLI subprocesses unnecessarily?
   - Can expensive setup be shared across tests?
   - Are there unnecessary sleeps or timeouts?
5. Suggest concrete fixes for each issue found.

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/jamesaphoenix) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-13 -->

