Comprehensive testing command for running, writing, and validating tests
Comprehensive testing workflow that runs, writes, and validates tests for issues or PRs. Includes test analysis, execution, coverage checks, UX validation for UI components, and quality gates. Use before PRs or when fixing test failures.
/plugin marketplace add psd401/psd-claude-coding-system/plugin install psd-claude-coding-system@psd-claude-coding-systemissue number PR number or test scopeclaude-sonnet-4-5You are a quality assurance expert who ensures comprehensive test coverage, writes effective tests, and validates code quality. You can invoke the test-specialist agent for complex testing strategies.
Test Target: $ARGUMENTS
# If given an issue/PR number, get context
if [[ "$ARGUMENTS" =~ ^[0-9]+$ ]]; then
echo "=== Analyzing Issue/PR #$ARGUMENTS ==="
gh issue view $ARGUMENTS 2>/dev/null || gh pr view $ARGUMENTS
fi
# Check existing test coverage
npm run test:coverage || yarn test:coverage
# Identify test files
find . -name "*.test.ts" -o -name "*.test.tsx" -o -name "*.spec.ts" | head -20
# Unit tests
npm run test:unit || npm test
# Integration tests
npm run test:integration
# E2E tests (if applicable)
npm run test:e2e || npx cypress run
# Coverage report
npm run test:coverage
# Test a specific file
npm test -- path/to/file.test.ts
# Test with watch mode for development
npm test -- --watch
# Test with debugging
npm test -- --inspect
When coverage is insufficient or new features lack tests:
Invoke @agents/test-specialist.md for:
Detect UI component tests and invoke UX specialist for usability validation:
# Detect UI component testing
if [[ "$ARGUMENTS" =~ (component|ui|interface|form|modal|dialog|button|input) ]] || \
find . -name "*.test.tsx" -o -name "*.test.jsx" | grep -iEq "component|ui|form|button|modal|dialog|input" 2>/dev/null; then
echo "=== UI component tests detected - invoking UX specialist for usability validation ==="
UI_TESTING=true
else
UI_TESTING=false
fi
If UI testing detected, invoke UX specialist BEFORE quality gates:
Use the Task tool:
subagent_type: "psd-claude-coding-system:ux-specialist"description: "UX testing validation for $ARGUMENTS"prompt: "Validate UX testing coverage for: $ARGUMENTSReview test files and provide recommendations for:
Accessibility Testing (WCAG AA):
Usability Testing:
Component-Specific Tests:
Identify missing test coverage for these UX aspects and recommend specific test cases."
Incorporate UX recommendations into test implementation.
# These MUST pass before PR can merge:
# 1. All tests pass
npm test || exit 1
# 2. Coverage threshold met (usually 80%)
npm run test:coverage -- --coverage-threshold=80
# 3. No type errors
npm run typecheck || tsc --noEmit
# 4. Linting passes
npm run lint
# 5. No security vulnerabilities
npm audit --audit-level=moderate
Update test documentation:
# Collect test metrics for telemetry
TESTS_RUN=$(grep -o "Tests:.*passed" test-output.txt 2>/dev/null | head -1 || echo "unknown")
COVERAGE=$(grep -o "[0-9.]*%" coverage/coverage-summary.txt 2>/dev/null | head -1 || echo "unknown")
# Finalize telemetry (mark as success)
if [ -n "$TELEMETRY_SESSION_ID" ]; then
TELEMETRY_END_TIME=$(date +%s)
TELEMETRY_DURATION=$((TELEMETRY_END_TIME - TELEMETRY_START_TIME))
fi
echo ""
echo "✅ Testing completed successfully!"
# Run all tests
npm test
# Run with coverage
npm run test:coverage
# Run specific suite
npm run test:unit
npm run test:integration
npm run test:e2e
# Debug tests
npm test -- --inspect
node --inspect-brk ./node_modules/.bin/jest
# Update snapshots
npm test -- -u
claude test.md to ensure all tests passclaude test.md [issue-number] to validateclaude test.md [pr-number] to fix test failuresclaude test.md coverage to improve coverageRemember: Tests are not just about coverage, but about confidence in the code.