-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_lighthouse.sh
More file actions
executable file
Β·44 lines (30 loc) Β· 1.03 KB
/
run_lighthouse.sh
File metadata and controls
executable file
Β·44 lines (30 loc) Β· 1.03 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
#!/bin/bash
#!/bin/bash
# Define folder paths
FOLDER="generated_html_pages"
REPORT_DIR="lighthouse_reports"
# Create results folder if it doesn't exist
mkdir -p "$REPORT_DIR"
# Start a local HTTP server in the background
echo "π Starting local HTTP server..."
npx http-server -p 8080 > /dev/null 2>&1 &
SERVER_PID=$!
# Wait a few seconds to ensure the server is running
sleep 3
# Base URL for testing
BASE_URL="http://localhost:8080"
# Loop through all HTML files
for file in "$FOLDER"/*.html; do
filename=$(basename -- "$file")
report_name="${REPORT_DIR}/${filename%.html}.report.json"
# Construct the correct URL
url="${BASE_URL}/${FOLDER}/${filename}"
echo "π Running Lighthouse for: $url"
# Run Lighthouse
lighthouse "$url" --quiet --only-categories=accessibility --output json --output-path "$report_name"
echo "β
Report saved: $report_name"
done
# Stop the server after all tests complete
echo "π Stopping local HTTP server..."
kill $SERVER_PID
echo "π All Lighthouse tests completed!"