Skip to content

Commit dcd5a1d

Browse files
committed
working
1 parent c69cdd6 commit dcd5a1d

13 files changed

Lines changed: 348 additions & 42 deletions

File tree

examples/android/devbox.d/android/devices/devices.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
}
1515
],
1616
"checksum": "2f3ab0e3cefd3e9909185c0717dc9d63038da1e81625eb6fce585e3af446bfef",
17-
"generated_at": "2026-02-12T03:29:12Z"
17+
"generated_at": "2026-02-12T06:21:41Z"
1818
}

examples/ios/devbox.d/ios/devices/devices.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
}
1111
],
1212
"checksum": "dd575d31a5adf2f471655389df301215f6ef7130ca284d433929b08b68e42890",
13-
"generated_at": "2026-02-12T06:18:42Z"
13+
"generated_at": "2026-02-12T06:21:46Z"
1414
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"devices": [
33
{
4-
"name": "medium_phone_api35",
5-
"api": 35,
4+
"name": "medium_phone_api36",
5+
"api": 36,
66
"device": "medium_phone",
77
"tag": "google_apis"
88
},
@@ -13,6 +13,6 @@
1313
"tag": "google_apis"
1414
}
1515
],
16-
"checksum": "bbbd59b479f190024f05b0b381db107a1b9f55c4da8ffabdd6e0d903f541370b",
17-
"generated_at": "2026-02-12T06:18:58Z"
16+
"checksum": "2f3ab0e3cefd3e9909185c0717dc9d63038da1e81625eb6fce585e3af446bfef",
17+
"generated_at": "2026-02-12T06:39:26Z"
1818
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "medium_phone_api35",
3-
"api": 35,
2+
"name": "medium_phone_api36",
3+
"api": 36,
44
"device": "medium_phone",
55
"tag": "google_apis"
66
}

examples/react-native/devbox.d/ios/devices/devices.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
}
1111
],
1212
"checksum": "dd575d31a5adf2f471655389df301215f6ef7130ca284d433929b08b68e42890",
13-
"generated_at": "2026-02-12T06:18:59Z"
13+
"generated_at": "2026-02-12T06:39:27Z"
1414
}

examples/react-native/devbox.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,19 @@
4444
"devbox run build:web"
4545
],
4646
"start:android": [
47-
"devbox services start android-emulator || devbox services up -b android-emulator",
48-
"npx react-native run-android --no-packager"
47+
"bash scripts/start-with-metro.sh android ${1:-${ANDROID_DEFAULT_DEVICE:-max}}"
4948
],
5049
"start:ios": [
51-
"devbox services start ios-simulator || devbox services up -b ios-simulator",
52-
"npx react-native run-ios --no-packager"
50+
"bash scripts/start-with-metro.sh ios ${1:-${IOS_DEFAULT_DEVICE:-max}}"
51+
],
52+
"start:web": [
53+
"bash scripts/start-with-metro.sh web"
54+
],
55+
"start:metro": [
56+
"metro.sh start ${1:-default}"
57+
],
58+
"stop:metro": [
59+
"metro.sh stop ${1:-default}"
5360
],
5461
"start:sim": [
5562
"ios.sh simulator start ${1:-${IOS_DEFAULT_DEVICE:-max}}"
@@ -77,6 +84,9 @@
7784
],
7885
"test:e2e:all": [
7986
"process-compose -f tests/test-suite-all.yaml --no-server --tui=${TEST_TUI:-false}"
87+
],
88+
"test:e2e:web": [
89+
"process-compose -f tests/test-suite-web.yaml --no-server --tui=${TEST_TUI:-false}"
8090
]
8191
}
8292
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#!/usr/bin/env bash
2+
# Helper script to start Metro and deploy React Native app
3+
# Usage: start-with-metro.sh <platform> [device]
4+
# Platform: android, ios, web
5+
# Device: optional device name (for android/ios)
6+
7+
set -euo pipefail
8+
9+
PLATFORM="${1:-}"
10+
DEVICE="${2:-}"
11+
12+
if [ -z "$PLATFORM" ]; then
13+
echo "Usage: start-with-metro.sh <platform> [device]"
14+
echo "Platform: android, ios, web"
15+
exit 1
16+
fi
17+
18+
# Source React Native lib
19+
. "${REACT_NATIVE_VIRTENV}/scripts/lib/lib.sh"
20+
21+
echo "🚀 Starting React Native for $PLATFORM..."
22+
23+
# Check if Metro is already running for this platform
24+
if metro.sh status "$PLATFORM" 2>&1 | grep -q "Running"; then
25+
echo "✓ Metro already running for $PLATFORM"
26+
else
27+
# Allocate port and start Metro
28+
echo "📡 Allocating Metro port..."
29+
metro_port=$(rn_allocate_metro_port "$PLATFORM")
30+
rn_save_metro_env "$PLATFORM" "$metro_port"
31+
32+
echo "🎬 Starting Metro bundler on port $metro_port..."
33+
metro.sh start "$PLATFORM" &
34+
METRO_PID=$!
35+
36+
# Wait for Metro to be healthy
37+
echo "⏳ Waiting for Metro to be ready..."
38+
max_attempts=30
39+
attempt=0
40+
while [ $attempt -lt $max_attempts ]; do
41+
if metro.sh health "$PLATFORM" "$PLATFORM" 2>/dev/null; then
42+
echo "✓ Metro is ready"
43+
break
44+
fi
45+
attempt=$((attempt + 1))
46+
sleep 2
47+
done
48+
49+
if [ $attempt -ge $max_attempts ]; then
50+
echo "✗ Metro failed to start within timeout"
51+
kill $METRO_PID 2>/dev/null || true
52+
exit 1
53+
fi
54+
fi
55+
56+
# Source Metro environment
57+
. "${REACT_NATIVE_VIRTENV}/metro/env-${PLATFORM}.sh"
58+
59+
# Deploy based on platform
60+
case "$PLATFORM" in
61+
android)
62+
echo "📲 Deploying to Android..."
63+
if [ -n "$DEVICE" ]; then
64+
# Start specific device
65+
android.sh emulator start "$DEVICE"
66+
fi
67+
npx react-native run-android --no-packager
68+
echo "✓ Android app deployed on port $METRO_PORT"
69+
;;
70+
71+
ios)
72+
echo "📲 Deploying to iOS..."
73+
if [ -n "$DEVICE" ]; then
74+
# Start specific device
75+
ios.sh simulator start "$DEVICE"
76+
fi
77+
npx react-native run-ios --no-packager
78+
echo "✓ iOS app deployed on port $METRO_PORT"
79+
;;
80+
81+
web)
82+
echo "🌐 Opening web browser..."
83+
# Create web build directory
84+
mkdir -p web/build
85+
86+
# Open default browser
87+
if command -v open >/dev/null 2>&1; then
88+
open "http://localhost:$METRO_PORT"
89+
elif command -v xdg-open >/dev/null 2>&1; then
90+
xdg-open "http://localhost:$METRO_PORT"
91+
elif command -v start >/dev/null 2>&1; then
92+
start "http://localhost:$METRO_PORT"
93+
else
94+
echo "⚠ Could not detect browser launcher"
95+
echo " Please open: http://localhost:$METRO_PORT"
96+
fi
97+
echo "✓ Browser opened to http://localhost:$METRO_PORT"
98+
;;
99+
100+
*)
101+
echo "✗ Unknown platform: $PLATFORM"
102+
echo " Supported: android, ios, web"
103+
exit 1
104+
;;
105+
esac
106+
107+
echo ""
108+
echo "✓ React Native $PLATFORM is running!"
109+
echo " Metro port: $METRO_PORT"
110+
echo ""
111+
echo "To stop Metro:"
112+
echo " metro.sh stop $PLATFORM"

examples/react-native/tests/README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,29 @@ This directory contains E2E test suites for React Native development.
1111
# Run Android tests only (fast - skips iOS setup)
1212
./tests/run-android-tests.sh
1313

14+
# Run web tests only (fastest - Metro + browser)
15+
devbox run test:e2e:web
16+
1417
# Run all tests (both platforms)
1518
devbox run test:e2e:all
1619
```
1720

21+
## Development Commands
22+
23+
```bash
24+
# Start React Native with Metro for each platform
25+
devbox run start:android # Start Metro + deploy to Android
26+
devbox run start:ios # Start Metro + deploy to iOS
27+
devbox run start:web # Start Metro + open browser
28+
29+
# Manual Metro control
30+
devbox run start:metro android # Start Metro for android suite
31+
devbox run stop:metro android # Stop Metro for android suite
32+
metro.sh status android # Check Metro status
33+
metro.sh health android android # Health check (exit code only)
34+
metro.sh clean android # Clean up Metro state files
35+
```
36+
1837
## Test Modes: --pure vs Development
1938

2039
The tests support two modes for different use cases:
@@ -59,7 +78,8 @@ devbox run test:e2e:android
5978

6079
- **test-suite-ios.yaml** - iOS simulator build and deployment
6180
- **test-suite-android.yaml** - Android emulator build and deployment
62-
- **test-suite-all.yaml** - Both platforms in parallel
81+
- **test-suite-web.yaml** - Web browser Metro bundle (fastest)
82+
- **test-suite-all.yaml** - Both mobile platforms in parallel
6383

6484
## Parallel Testing Multiple Versions
6585

examples/react-native/tests/test-suite-all.yaml renamed to examples/react-native/tests/test-suite-all-e2e.yaml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,16 +214,7 @@ processes:
214214
timeout_seconds: 5
215215
readiness_probe:
216216
exec:
217-
command: |
218-
# Source Metro environment to get correct port
219-
. ${REACT_NATIVE_VIRTENV}/metro/env-all.sh
220-
221-
# Check if Metro server is up on allocated port
222-
curl -sf http://localhost:$METRO_PORT/status >/dev/null || exit 1
223-
224-
# Verify Metro can serve bundles for both platforms
225-
curl -sf -I "http://localhost:$METRO_PORT/index.bundle?platform=android&dev=true" | grep -q "HTTP.*200" || exit 1
226-
curl -sf -I "http://localhost:$METRO_PORT/index.bundle?platform=ios&dev=true" | grep -q "HTTP.*200" || exit 1
217+
command: "metro.sh health all ios"
227218
initial_delay_seconds: 5
228219
period_seconds: 5
229220
timeout_seconds: 60

examples/react-native/tests/test-suite-android.yaml renamed to examples/react-native/tests/test-suite-android-e2e.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,7 @@ processes:
143143
timeout_seconds: 5
144144
readiness_probe:
145145
exec:
146-
command: |
147-
# Source Metro environment to get correct port
148-
. ${REACT_NATIVE_VIRTENV}/metro/env-android.sh
149-
150-
# Check if Metro server is up on allocated port
151-
curl -sf http://localhost:$METRO_PORT/status >/dev/null || exit 1
152-
153-
# Verify Metro can actually serve the bundle (without downloading it)
154-
curl -sf -I "http://localhost:$METRO_PORT/index.bundle?platform=android&dev=true" | grep -q "HTTP.*200" || exit 1
146+
command: "metro.sh health android android"
155147
initial_delay_seconds: 5
156148
period_seconds: 5
157149
timeout_seconds: 60

0 commit comments

Comments
 (0)