| name | run-unit-tests |
| description | Run all unit and integration tests and generate a comprehensive baseline report |
| user-invocable | true |
| disable-model-invocation | true |
Run Unit Tests - Baseline Report
Execute all unit tests and integration tests across the workspace and generate a comprehensive baseline report for tracking test health.
Process
Step 1: Run All Unit Tests
Execute unit tests across all projects (excluding E2E):
pnpm exec nx run-many --target=vite:test --exclude=teensyrom-ui-e2e 2>&1
Capture from output:
- List of projects tested
- Pass/fail status for each project
- Number of tests passed/failed per project
- Any console errors or warnings
Step 2: Run Integration Tests
Execute infrastructure integration tests:
pnpm nx run infrastructure:test:integration 2>&1
Capture from output:
- Test file results
- Pass/fail/skip counts
- Any DI errors or assertion failures
- MSW-related issues
Step 3: Check for TypeScript/ESLint Errors
Check for any compilation or lint errors that might indicate test infrastructure issues (e.g. pnpm nx run-many --target=lint or the workspace's TypeScript check).
Output Format
Generate a comprehensive markdown report with the following structure:
# Test Baseline Report
**Date**: [Current Date]
**Generated By**: Test Technician 🔧
**Scope**: All unit tests + integration tests in workspace (excluding E2E)
---
## Executive Summary
| Metric | Count |
|--------|-------|
| **Total Test Files** | [count] |
| **Passing Test Suites** | [count] |
| **Failing Test Suites** | [count] |
| **Total Tests Passing** | [count] |
| **Total Tests Failing** | [count] |
| **Tests Skipped** | [count and reason] |
| **Projects with Issues** | [count] |
### Projects Analyzed
| Project | Status | Tests Passed | Tests Failed | Notes |
|---------|--------|--------------|--------------|-------|
| [project-name] | ✅ Pass / ❌ FAIL | [count] | [count] | [notes] |
...
---
## Integration Test Summary
**Command**: `pnpm nx run infrastructure:test:integration`
| Test File | Status | Passed | Failed | Skipped | Notes |
|-----------|--------|--------|--------|---------|-------|
| [file.spec.ts] | ✅ Pass / ❌ FAIL / ⏭️ Skip | [n] | [n] | [n] | [notes] |
...
**Totals**: [summary counts]
---
## Failure Categories
Group failures into categories:
### Category N: [Category Name]
**Priority**: 🔴 High / 🟠 Medium-High / 🟡 Medium
**Affected Tests**: [count] tests across [count] files
[Description of the category]
---
## Detailed Failure Analysis
For each failing test or test suite:
### [Test Suite / Component Name]
**File**: `[file path]`
**Test**: `[test name]`
**Error**:
[Error message and relevant stack trace]
**Root Cause**: [Analysis of why the test fails]
**Recommended Fix**:
```typescript
[Code snippet showing the fix]
Files to Modify:
Non-Blocking Warnings
Document any warnings that appear but don't cause test failures:
[Warning Type]
Affected Files: [list]
Warning: [message]
Impact: [description - tests pass despite warning]
Recommended Fix (Nice-to-have): [optional fix]
Repair Plan Summary
High Priority (Blocking CI)
| Issue | Files | Effort | Fix Type |
|---|
| [issue] | [count] | [time] | [type] |
Medium Priority (Clean Build)
Low Priority (Nice-to-have)
Files Requiring Modification
Spec Files ([count] files)
[file path] - [issue summary]
...
Configuration Files ([count] files)
[file path] - [issue summary]
...
Recommended Execution Order
-
Phase 1 - [Name] ([time])
-
Phase 2 - [Name] ([time])
Total Estimated Time: [estimate]
Validation Commands
After repairs, run the following to verify:
pnpm exec nx run-many --target=vite:test --exclude=teensyrom-ui-e2e
pnpm nx run infrastructure:test:integration
pnpm exec nx run-many --target=vite:test --exclude=teensyrom-ui-e2e; pnpm nx run infrastructure:test:integration
Expected result: All projects should pass with 0 failures.
Report generated by Test Technician 🔧
## Analysis Guidelines
When analyzing test failures, categorize them into these common patterns:
### Common Failure Patterns
1. **Missing DI Providers**
- Look for `NullInjectorError` messages
- Identify the missing injection token
- Document the required provider configuration
2. **Assertion Mismatches**
- Compare expected vs received values
- Check if object shape changed (new properties)
- Recommend `toMatchObject` vs `toEqual` as appropriate
3. **Configuration Issues**
- No test files found (project config)
- Test target misconfiguration
- Environment variable issues
4. **Angular Injection Context Errors**
- `NG0203` errors from `inject()` outside context
- Service instantiation issues
- Recommend `TestBed.inject()` or `runInInjectionContext()`
5. **Environment-Gated Tests**
- Tests skipped due to env var checks
- Live API tests requiring backend
- Document skip reasons and conditions
6. **Async/Timing Issues**
- fakeAsync zone errors
- Unresolved promises
- Missing `flush()` or `tick()` calls
### Priority Classification
- 🔴 **High**: Blocks CI, prevents merge
- 🟠 **Medium-High**: Tests fail but don't block
- 🟡 **Medium**: Configuration issues, skipped tests
- 🟢 **Low**: Warnings, nice-to-have improvements
## Reference Documentation
- [Test Repair Master Plan](../../../docs/projects/TEST-REPAIR/TEST-REPAIR-MASTER-PLAN.md) - Previous repair project reference
## Notes
- Run tests with `2>&1` to capture both stdout and stderr
- Parse Nx output carefully - cached results show differently than fresh runs
- Integration tests may have intentional skips for live API tests
- Check for polyfill warnings (ResizeObserver, MediaDevices) as quality indicators