forked from gnowgi/ndf-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.sh
More file actions
executable file
·152 lines (125 loc) · 3.44 KB
/
run_tests.sh
File metadata and controls
executable file
·152 lines (125 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
# NodeBook Test Script
set -e # Exit on any error
echo "🧪 NodeBook Testing Pipeline"
echo "================================"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if we're in the right directory
if [ ! -f "package.json" ]; then
print_error "Please run this script from the project root directory"
exit 1
fi
# Function to run backend tests
run_backend_tests() {
print_status "Running backend tests..."
cd nodebook-base
# Check if dependencies are installed
if [ ! -d "node_modules" ]; then
print_status "Installing backend dependencies..."
npm install
fi
# Run tests
if npm test -- registry.test.js cnl-parser-water.test.js; then
print_success "Backend tests passed!"
else
print_error "Backend tests failed!"
return 1
fi
cd ..
}
# Function to run frontend tests
run_frontend_tests() {
print_status "Running frontend tests..."
cd nodebook-base/frontend
# Check if dependencies are installed
if [ ! -d "node_modules" ]; then
print_status "Installing frontend dependencies..."
npm install
fi
# Run linting
print_status "Running linting..."
if npm run lint; then
print_success "Linting passed!"
else
print_warning "Linting issues found. Run 'npm run lint:fix' to auto-fix."
fi
# Run type checking
print_status "Running type checking..."
if npm run type-check; then
print_success "Type checking passed!"
else
print_error "Type checking failed!"
return 1
fi
cd ../..
}
# Main execution
main() {
local exit_code=0
# Parse command line arguments
RUN_BACKEND=true
RUN_FRONTEND=false
while [[ $# -gt 0 ]]; do
case $1 in
--backend-only)
RUN_FRONTEND=false
shift
;;
--frontend-only)
RUN_BACKEND=false
shift
;;
--help)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --backend-only Run only backend tests"
echo " --frontend-only Run only frontend tests"
echo " --help Show this help message"
exit 0
;;
*)
print_error "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
# Run selected tests
if [ "$RUN_BACKEND" = true ]; then
if ! run_backend_tests; then
exit_code=1
fi
fi
if [ "$RUN_FRONTEND" = true ]; then
if ! run_frontend_tests; then
exit_code=1
fi
fi
# Final summary
echo ""
echo "================================"
if [ $exit_code -eq 0 ]; then
print_success "All tests completed successfully! 🎉"
else
print_error "Some tests failed. Please fix the issues before committing. ❌"
fi
echo "================================"
exit $exit_code
}
# Run main function with all arguments
main "$@"