Test coverage check and creation workflow. Ensures tests exist for all features. Creates unit and E2E tests when missing following acceptance criteria. Use during validation before code review.
"No feature passes QA without tests. If tests don't exist, we create them."
Use when:
CRITICAL: NEVER CREATE FAKE OR TRIVIAL TESTS. If a test cannot be created with meaningful assertions based on the specs/gdd requirements, DO NOT CREATE A TEST. Instead, report the issue to PM and document the gap in test coverage in the task comments and close the task as completed with observations.
⚠️ CRITICAL: Focus on unit tests for code quality verification.
QA validates implementation through:
Avoid browser/E2E testing - AI agents do not reliably handle browser automation, which delays validation. QA must be smart enough to validate code quality through static analysis and unit testing.
| Component Type | Unit Test Coverage | Spec Validation |
|---|---|---|
| Gameplay mechanic | YES (systems, components) | YES |
| UI Component | YES (rendering, behavior) | YES |
| Visual effect | YES (shader/material params) | YES |
| Service/Utility | YES (pure functions) | MAYBE |
| Asset (model/texture) | N/A | YES (visual inspection) |
CRITICAL: NEVER CREATE FAKE OR TRIVIAL TESTS. If a meaningful unit test cannot be created based on implementation specs, report the gap to PM and document as observation in task comments.
# 1. Get the task ID from PRD
# 2. Check test coverage for modified files
# 3. If coverage incomplete, invoke test-creator
# 4. Verify tests pass before proceeding
src/ structure in src/tests/src/components/game/player/index.ts → src/tests/components/game/player/index.test.tssrc/tests/.../{name}.test.ts exists# Read PRD for current task
cat prd.json | jq '.items[] | select(.id == "{taskId}")'
# Extract:
# - acceptance criteria
# - modified files (from git diff or PRD)
# - feature type (component, service, gameplay, etc.)
# Get list of modified source files
git diff --name-only HEAD~5 HEAD | grep '^src/'
# Or read from task context
# Common patterns:
# - src/components/**/*.tsx
# - src/services/**/*.ts
# - src/stores/**/*.ts
# - src/utils/**/*.ts
# - src/ecs/**/*.ts
For each source file:
# Convert source path to test path
SOURCE="src/components/game/player/index.ts"
TEST="src/tests/components/game/player/index.test.ts"
# Check if test exists
if [ -f "$TEST" ]; then
echo "Test exists: $TEST"
else
echo "MISSING TEST: $TEST"
fi
| Source File Pattern | Requires Unit Test? |
|---|---|
src/components/**/*.tsx |
Yes |
src/services/**/*.ts |
Yes |
src/stores/**/*.ts |
Yes |
src/utils/**/*.ts |
Yes |
src/ecs/**/*.ts |
Yes |
src/audio/**/*.ts |
Yes |
src/materials/**/*.ts |
No (visual asset) |
src/shaders/**/*.ts |
No (visual asset) |
If tests are missing, invoke the test-creator sub-agent:
Task({
subagent_type: "test-creator",
description: "Create tests for {feature-name}",
prompt: `
Create tests for the following task:
Task ID: {taskId}
Title: {title}
Acceptance Criteria:
{list of acceptance criteria}
Modified Files:
{list of modified files}
GDD Specs:
{relevant GDD sections}
Create:
1. Unit tests in src/tests/ mirroring src structure
2. E2E tests in tests/e2e/ with {feature}-suite.spec.ts naming
Ensure all acceptance criteria have test coverage.
`
})
After tests are created (or if they already existed):
# Run unit tests
npm run test
# Verify tests pass
# Check exit codes and output
When tests fail, determine the root cause.
See
qa-workflowskill for the Test Failure Decision Tree and how to distinguish test vs game code issues.
If issue is in test code, QA may fix:
# Edit test file directly (QA has permission for test files)
Edit src/tests/{path}/{feature}.test.ts
# Re-run specific test
npm run test -- src/tests/{path}/{feature}.test.ts
# Verify fix
git diff src/tests/{path}/{feature}.test.ts
If issue is in game code, use qa-bug-reporting skill:
## Bug Report: {TASK_ID} - Test Failure
**Severity**: High
**Category**: Test / Runtime
### Summary
Unit test "{test_name}" failed due to game code not meeting acceptance criteria.
### Test That Failed
- File: src/tests/{path}/{feature}.test.ts
- Test: "{test_name}"
- Error: {error_message}
### Acceptance Criteria Not Met
- {criterion from test plan}
### Expected vs Actual
- Expected: {what test expects}
- Actual: {what actually happened}
### Test Output
\`\`\`
{npm run test output}
\`\`\`
After checking coverage, create a report:
## Test Coverage Report for {taskId}
### Unit Tests
| Source File | Test File | Status |
| ------------ | --------- | ------ |
| src/components/game/player/index.ts | src/tests/components/game/player/index.test.ts | ✅ EXISTS / ❌ MISSING |
| src/services/ShootingService.ts | src/tests/services/ShootingService.test.ts | ✅ EXISTS / ❌ MISSING |
### Coverage Summary
- Unit test coverage: X%
- Action required: CREATE TESTS / NO ACTION
┌─────────────────┐
│ Start Check │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Any source │
│ files modified? │
└────────┬────────┘
│
┌────────────┴────────────┐
│ NO │ YES
▼ ▼
┌──────────┐ ┌──────────────────┐
│ SKIP │ │ Check each source │
│ (assets │ │ file for test │
│ only) │ └─────────┬────────┘
└──────────┘ │
┌────────────┴────────────┐
│ │
Test exists Test missing
│ │
▼ ▼
┌──────────┐ ┌──────────────┐
│ Mark OK │ │ Invoke test- │
└──────────┘ │ creator │
└──────────────┘
Add this step between "Task Research" and "Code Review":
6. TASK RESEARCH (MANDATORY)
↓
7. TEST COVERAGE CHECK (NEW)
- Check unit test coverage
- Create missing tests via test-creator
↓
8. Run validation: code review → type-check → lint → test → build
Invoke test-creator when:
.test.ts in src/tests/Do NOT invoke test-creator when:
After test-creator completes:
# 1. Verify tests were created
git status
git diff --cached
# 2. Run unit tests
npm run test
# 3. Verify coverage
npm run test -- --coverage
# 4. Proceed with validation workflow
PRD Item:
{
"id": "feat-movement-001",
"title": "WASD Movement System",
"acceptanceCriteria": [
"Player moves forward when W is pressed",
"Player moves left when A is pressed",
"Player moves backward when S is pressed",
"Player moves right when D is pressed"
],
"files": [
"src/components/game/player/index.tsx",
"src/ecs/systems/MovementSystem.ts"
]
}
Coverage Check:
# Unit tests
src/tests/components/game/player/index.test.ts ❌ MISSING
src/tests/ecs/systems/MovementSystem.test.ts ❌ MISSING
Action: Invoke test-creator to create missing tests
PRD Item:
{
"id": "feat-ui-001",
"title": "Health Bar Component",
"acceptanceCriteria": [
"Displays current health",
"Updates when health changes",
"Shows correct color based on health percentage"
],
"files": [
"src/components/ui/HealthBar.tsx"
]
}
Coverage Check:
# Unit tests
src/tests/components/ui/HealthBar.test.ts ❌ MISSING
Action: Invoke test-creator to create missing unit tests