Files
scripts/utils/test-all.sh
2026-02-09 21:51:52 -08:00

62 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# Load shared libraries
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../lib/init.sh"
# Test All Projects Script
# Runs tests for all projects that have test scripts
set -e
echo "🧪 Running tests for all projects..."
PROJECTS_DIR="."
TESTED=0
FAILED=0
test_project() {
local project=$1
if [ -f "$project/package.json" ]; then
cd "$project"
# Check if test script exists
if grep -q "\"test\"" package.json; then
echo "🧪 Testing $project..."
if npm test 2>/dev/null || pnpm test 2>/dev/null; then
echo "$project - Tests passed"
((TESTED++))
else
echo "$project - Tests failed"
((FAILED++))
fi
else
echo " ⏭️ $project - No test script"
fi
cd ..
fi
}
echo "📋 Testing projects..."
# Test all projects with package.json
for dir in */; do
if [ -d "$dir" ] && [ "$dir" != "node_modules/" ] && [ "$dir" != ".git/" ] && [ "$dir" != "scripts/" ]; then
test_project "$dir"
fi
done
echo ""
echo "📊 Test Summary:"
echo " ✅ Tested: $TESTED"
echo " ❌ Failed: $FAILED"
if [ $FAILED -gt 0 ]; then
exit 1
fi
echo "✅ All tests passed!"