#!/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!"