Git workflow, code quality, context management and testing commands: - commit, push, pr, issue - git operations - simplify, refactor, verify, check - code quality - catchup, onboard, save, cleanup - context management - test, format, sync - development utilities Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2.6 KiB
Smart Test Runner
Pre-computed Context
Test Framework Detection:
!cat package.json 2>/dev/null | grep -E '"(jest|vitest|mocha|ava|tape)"' | head -3 || echo "No JS test framework"
Python Test Framework:
!cat pyproject.toml setup.cfg 2>/dev/null | grep -E '(pytest|unittest|nose)' | head -3 || echo "No Python test framework"
Test Scripts:
!cat package.json 2>/dev/null | grep -E '"test' | head -5 || echo "No test scripts"
Changed Files:
!git diff --name-only HEAD~3 2>/dev/null | head -10
Related Test Files:
!git diff --name-only HEAD~3 2>/dev/null | sed 's/\.\(ts\|tsx\|js\|jsx\)$/.test.\1/' | xargs -I{} sh -c 'test -f {} && echo {}' 2>/dev/null | head -5
Instructions
You are running tests intelligently - focusing on changed files when possible.
Detect Test Framework
JavaScript/TypeScript
- Jest
npx jest --passWithNoTests
- Vitest
npx vitest run
- npm test script
npm test
Python
- pytest
pytest -v
- unittest
python -m unittest discover
Smart Test Selection
If no argument provided, run tests related to changed files:
Jest - Run related tests
npx jest --findRelatedTests $(git diff --name-only HEAD~3 | tr '\n' ' ')
Jest - Run changed test files only
npx jest --testPathPattern="$(git diff --name-only HEAD~3 | grep -E '\.test\.(ts|tsx|js|jsx)$' | tr '\n' '|' | sed 's/|$//')"
Vitest - Run changed
npx vitest run --changed HEAD~3
pytest - Run specific files
pytest $(git diff --name-only HEAD~3 | grep -E '_test\.py$|test_.*\.py$' | tr '\n' ' ')
With Pattern Argument
If argument provided, run tests matching that pattern:
# Jest
npx jest --testPathPattern="$ARGUMENTS"
# Vitest
npx vitest run "$ARGUMENTS"
# pytest
pytest -k "$ARGUMENTS"
Test Output
Show test results with appropriate verbosity:
# Jest with coverage
npx jest --coverage --passWithNoTests
# pytest verbose
pytest -v --tb=short
On Failure
If tests fail:
- Show the failing test names
- Show the error messages
- Identify the source file that likely caused the failure
- Suggest fix or ask if you should investigate
Common Options
Run all tests:
/workflow:test --all
Run with coverage:
/workflow:test --coverage
Run in watch mode:
npx jest --watch
# or
npx vitest
Run specific test file:
/workflow:test src/utils.test.ts