forked from nathydre21/wata-board
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-tests.sh
More file actions
170 lines (146 loc) · 4.81 KB
/
Copy pathrun-tests.sh
File metadata and controls
170 lines (146 loc) · 4.81 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/bin/bash
# Comprehensive Test Execution Script for Wata-Board
# This script runs all tests and generates coverage reports
echo "🚀 Starting Wata-Board Comprehensive Test Suite"
echo "=================================================="
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
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_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if Node.js is installed
if ! command -v node &> /dev/null; then
print_error "Node.js is not installed. Please install Node.js first."
exit 1
fi
# Check if npm is installed
if ! command -v npm &> /dev/null; then
print_error "npm is not installed. Please install npm first."
exit 1
fi
# Frontend Tests
print_status "Running Frontend Tests..."
cd wata-board-frontend
# Install dependencies if needed
if [ ! -d "node_modules" ]; then
print_status "Installing frontend dependencies..."
npm install
if [ $? -ne 0 ]; then
print_error "Failed to install frontend dependencies"
exit 1
fi
fi
# Run frontend unit tests with coverage
print_status "Running frontend unit tests with coverage..."
npm run test:coverage
if [ $? -eq 0 ]; then
print_success "Frontend unit tests passed"
else
print_error "Frontend unit tests failed"
exit 1
fi
# Run frontend E2E and Mobile tests
print_status "Running frontend E2E and Mobile tests (Playwright)..."
npm run test
if [ $? -eq 0 ]; then
print_success "Frontend E2E/Mobile tests passed"
else
print_error "Frontend E2E/Mobile tests failed"
exit 1
fi
# Backend Tests
print_status "Running Backend Tests..."
cd backend
# Install dependencies if needed
if [ ! -d "node_modules" ]; then
print_status "Installing backend dependencies..."
npm install
if [ $? -ne 0 ]; then
print_error "Failed to install backend dependencies"
exit 1
fi
fi
# Run backend tests with coverage
print_status "Running backend unit tests with coverage..."
npm run test:coverage
if [ $? -eq 0 ]; then
print_success "Backend tests passed"
else
print_error "Backend tests failed"
exit 1
fi
# Run migration tests
print_status "Running migration tests..."
npm run test -- --config jest.config.migrations.js
if [ $? -eq 0 ]; then
print_success "Migration tests passed"
else
print_error "Migration tests failed"
exit 1
fi
# Generate combined coverage report
print_status "Generating combined coverage report..."
cd ..
# Create coverage summary
echo "# Test Coverage Summary" > COVERAGE_SUMMARY.md
echo "" >> COVERAGE_SUMMARY.md
echo "## Frontend Coverage" >> COVERAGE_SUMMARY.md
if [ -f "wata-board-frontend/coverage/coverage-summary.json" ]; then
cat wata-board-frontend/coverage/coverage-summary.json >> COVERAGE_SUMMARY.md
else
echo "Frontend coverage report not found" >> COVERAGE_SUMMARY.md
fi
echo "" >> COVERAGE_SUMMARY.md
echo "## Backend Coverage" >> COVERAGE_SUMMARY.md
if [ -f "backend/coverage/coverage-summary.json" ]; then
cat backend/coverage/coverage-summary.json >> COVERAGE_SUMMARY.md
else
echo "Backend coverage report not found" >> COVERAGE_SUMMARY.md
fi
print_success "Combined coverage report generated: COVERAGE_SUMMARY.md"
# Test Results Summary
print_status "Generating test results summary..."
echo "# Test Results Summary" > TEST_RESULTS.md
echo "" >> TEST_RESULTS.md
echo "## Execution Time: $(date)" >> TEST_RESULTS.md
echo "" >> TEST_RESULTS.md
echo "## Test Suites" >> TEST_RESULTS.md
echo "- ✅ Frontend Unit Tests" >> TEST_RESULTS.md
echo "- ✅ Backend Unit Tests" >> TEST_RESULTS.md
echo "- ✅ Integration Tests" >> TEST_RESULTS.md
echo "- ✅ Mobile & Responsive Tests" >> TEST_RESULTS.md
echo "- ✅ Error Scenario Tests" >> TEST_RESULTS.md
echo "" >> TEST_RESULTS.md
echo "## Coverage Reports" >> TEST_RESULTS.md
echo "- Frontend: [wata-board-frontend/coverage/index.html](wata-board-frontend/coverage/index.html)" >> TEST_RESULTS.md
echo "- Backend: [wata-board-dapp/coverage/lcov-report/index.html](wata-board-dapp/coverage/lcov-report/index.html)" >> TEST_RESULTS.md
print_success "Test results summary generated: TEST_RESULTS.md"
# Final Summary
echo ""
echo "=================================================="
print_success "🎉 All tests completed successfully!"
echo ""
echo "📊 Coverage Reports:"
echo " Frontend: wata-board-frontend/coverage/index.html"
echo " Backend: backend/coverage/lcov-report/index.html"
echo ""
echo "📄 Summary Files:"
echo " Coverage: COVERAGE_SUMMARY.md"
echo " Results: TEST_RESULTS.md"
echo ""
print_status "To view detailed coverage reports, open the HTML files in your browser."
echo "=================================================="