Skip to content

Commit ec0b215

Browse files
abueideclaude
andcommitted
fix(rn): improve Metro error detection and use Debug builds for iOS
Two fixes: 1. Enhanced app verification to detect Metro connection errors: - Check for "unable to load script" and Metro connection failures - These appear in red box but not as "fatal" in logcat - Increased logcat tail from 50 to 100 lines - Separate checks for Metro errors vs fatal errors 2. Use Debug builds for iOS E2E tests: - Release builds use pre-bundled JS (don't connect to Metro) - Debug builds connect to Metro on RCT_METRO_PORT - Set IOS_BUILD_CONFIG=Debug in test suites This ensures tests fail when Metro connection is broken. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b4c64cc commit ec0b215

3 files changed

Lines changed: 56 additions & 16 deletions

File tree

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

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ processes:
172172
command: |
173173
set -e
174174
175-
BUILD_CONFIG="${IOS_BUILD_CONFIG:-Release}"
175+
BUILD_CONFIG="${IOS_BUILD_CONFIG:-Debug}"
176176
echo "Building React Native app (${BUILD_CONFIG})"
177177
178178
# Source Metro environment so React Native uses correct port
@@ -201,18 +201,48 @@ processes:
201201
verify-android-running:
202202
command: |
203203
echo "Waiting for Android app to start..."
204+
205+
# Resolve emulator serial for log checking
206+
serial=""
207+
state_dir="${ANDROID_RUNTIME_DIR:-.devbox/virtenv}/${SUITE_NAME:-default}"
208+
if [ -f "$state_dir/emulator-serial.txt" ]; then
209+
serial="$(cat "$state_dir/emulator-serial.txt")"
210+
fi
211+
if [ -z "$serial" ]; then
212+
serial="emulator-${EMU_PORT:-5554}"
213+
fi
214+
204215
max_attempts=15
205216
attempt=0
206217
while [ $attempt -lt $max_attempts ]; do
207-
if android.sh app status; then
208-
echo "✓ Android app is running"
209-
mkdir -p reports
210-
touch reports/.e2e-android-passed
211-
exit 0
218+
if ! android.sh app status; then
219+
attempt=$((attempt + 1))
220+
echo " Attempt $attempt/$max_attempts: App not running yet..."
221+
sleep 2
222+
continue
212223
fi
213-
attempt=$((attempt + 1))
214-
echo " Attempt $attempt/$max_attempts: App not running yet..."
215-
sleep 2
224+
225+
echo " App process is running, checking logs for errors..."
226+
227+
# Check logcat for Metro connection errors
228+
log_output=$(adb -s "$serial" logcat -d -s ReactNativeJS:* ReactNative:* -t 100 2>/dev/null || true)
229+
230+
if echo "$log_output" | grep -qi "unable.*load.*script\|could.*not.*connect.*metro\|connection.*refused.*8081"; then
231+
echo "ERROR: App cannot connect to Metro bundler:" >&2
232+
echo "$log_output" | grep -iE "unable|load|script|connect|metro|refused|8081" | tail -20 >&2
233+
exit 1
234+
fi
235+
236+
if echo "$log_output" | grep -qi "fatal.*error\|exception.*error"; then
237+
echo "ERROR: App encountered fatal errors:" >&2
238+
echo "$log_output" | grep -iE "fatal|exception" | tail -15 >&2
239+
exit 1
240+
fi
241+
242+
echo "✓ Android app is running and connected to Metro"
243+
mkdir -p reports
244+
touch reports/.e2e-android-passed
245+
exit 0
216246
done
217247
218248
echo "ERROR: Android app did not start within timeout" >&2

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,25 @@ processes:
149149
150150
echo " App process is running, checking logs for errors..."
151151
152-
# Check logcat for fatal errors
153-
log_output=$(adb -s "$serial" logcat -d -s ReactNativeJS:* ReactNative:* -t 50 2>/dev/null || true)
154-
if echo "$log_output" | grep -qi "fatal.*error\|exception.*error\|unable.*load.*script\|could.*not.*connect.*metro"; then
155-
echo "ERROR: App encountered errors:" >&2
156-
echo "$log_output" | grep -iE "fatal|exception|error|failed|unable|could not" | tail -15 >&2
152+
# Check logcat for errors (including Metro connection issues)
153+
log_output=$(adb -s "$serial" logcat -d -s ReactNativeJS:* ReactNative:* -t 100 2>/dev/null || true)
154+
155+
# Check for Metro connection errors (these appear in red box but may not be "fatal")
156+
if echo "$log_output" | grep -qi "unable.*load.*script\|could.*not.*connect.*metro\|connection.*refused.*8081"; then
157+
echo "ERROR: App cannot connect to Metro bundler:" >&2
158+
echo "$log_output" | grep -iE "unable|load|script|connect|metro|refused|8081" | tail -20 >&2
159+
exit 1
160+
fi
161+
162+
# Check for other fatal errors
163+
if echo "$log_output" | grep -qi "fatal.*error\|exception.*error"; then
164+
echo "ERROR: App encountered fatal errors:" >&2
165+
echo "$log_output" | grep -iE "fatal|exception" | tail -15 >&2
157166
exit 1
158167
fi
159168
160-
# Success: app is running and no fatal errors
161-
echo "✓ App is running (no fatal errors detected)"
169+
# Success: app is running and no errors
170+
echo "✓ App is running and connected to Metro"
162171
mkdir -p reports
163172
touch reports/.e2e-passed
164173
exit 0

examples/react-native/tests/test-suite-ios-e2e.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ version: "0.5"
33
environment:
44
- "IOS_DEVICE=${IOS_DEFAULT_DEVICE:-max}"
55
- "SUITE_NAME=rn-ios-e2e"
6+
- "IOS_BUILD_CONFIG=Debug"
67
- "ANDROID_SKIP_SETUP=1"
78
- "TEST_TUI=${TEST_TUI:-false}"
89
- "REACT_NATIVE_VIRTENV=${REACT_NATIVE_VIRTENV}"

0 commit comments

Comments
 (0)