Skip to content

Commit b505edd

Browse files
abueideclaude
andcommitted
fix(rn): improve Android app verification to catch Metro errors
Enhanced app verification to properly detect Metro connection failures: - Remove log tag filter (-s ReactNativeJS/ReactNative) - check ALL logs - Increase from 100 to 500 log lines to catch errors earlier in boot - Add 5 second wait after app process starts to let errors surface - Add "packaged.*correctly.*for.*release" to error patterns (full red box text) - Show 30 lines of matched patterns + 50 lines of full logs for debugging - Increase max_attempts from 15 to 20 This should properly fail the test when the "unable to load script" Metro error occurs, allowing us to debug the root cause. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 5a3f4ad commit b505edd

2 files changed

Lines changed: 30 additions & 15 deletions

File tree

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,9 @@ processes:
282282
if [ -z "$serial" ]; then
283283
serial="emulator-${EMU_PORT:-5554}"
284284
fi
285+
echo " Serial: $serial"
285286
286-
max_attempts=15
287+
max_attempts=20
287288
attempt=0
288289
while [ $attempt -lt $max_attempts ]; do
289290
if ! android.sh app status; then
@@ -293,20 +294,28 @@ processes:
293294
continue
294295
fi
295296
296-
echo " App process is running, checking logs for errors..."
297+
echo " App process is running, waiting 5 seconds for startup..."
298+
sleep 5
299+
300+
echo " Checking logs for errors..."
297301
298-
# Check logcat for Metro connection errors
299-
log_output=$(adb -s "$serial" logcat -d -s ReactNativeJS:* ReactNative:* -t 100 2>/dev/null || true)
302+
# Get recent logs from ALL tags (not just ReactNative), more lines
303+
log_output=$(adb -s "$serial" logcat -d -t 500 2>/dev/null || true)
300304
301-
if echo "$log_output" | grep -qi "unable.*load.*script\|could.*not.*connect.*metro\|connection.*refused.*8081"; then
305+
# Check for Metro connection errors (these appear in red box)
306+
if echo "$log_output" | grep -qi "unable.*load.*script\|could.*not.*connect.*metro\|connection.*refused.*8081\|packaged.*correctly.*for.*release"; then
302307
echo "ERROR: App cannot connect to Metro bundler:" >&2
303-
echo "$log_output" | grep -iE "unable|load|script|connect|metro|refused|8081" | tail -20 >&2
308+
echo "$log_output" | grep -iE "unable|load|script|connect|metro|refused|8081|packaged|release|bundle" | tail -30 >&2
309+
echo "" >&2
310+
echo "Full recent logs:" >&2
311+
echo "$log_output" | tail -50 >&2
304312
exit 1
305313
fi
306314
315+
# Check for other fatal errors
307316
if echo "$log_output" | grep -qi "fatal.*error\|exception.*error"; then
308317
echo "ERROR: App encountered fatal errors:" >&2
309-
echo "$log_output" | grep -iE "fatal|exception" | tail -15 >&2
318+
echo "$log_output" | grep -iE "fatal|exception" | tail -20 >&2
310319
exit 1
311320
fi
312321

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ processes:
166166
fi
167167
echo " Serial: $serial"
168168
169-
max_attempts=15
169+
max_attempts=20
170170
attempt=0
171171
while [ $attempt -lt $max_attempts ]; do
172172
# Check if app process is running using built-in command
@@ -177,22 +177,28 @@ processes:
177177
continue
178178
fi
179179
180-
echo " App process is running, checking logs for errors..."
180+
echo " App process is running, waiting 5 seconds for startup..."
181+
sleep 5
181182
182-
# Check logcat for errors (including Metro connection issues)
183-
log_output=$(adb -s "$serial" logcat -d -s ReactNativeJS:* ReactNative:* -t 100 2>/dev/null || true)
183+
echo " Checking logs for errors..."
184184
185-
# Check for Metro connection errors (these appear in red box but may not be "fatal")
186-
if echo "$log_output" | grep -qi "unable.*load.*script\|could.*not.*connect.*metro\|connection.*refused.*8081"; then
185+
# Get recent logs from ALL tags (not just ReactNative), more lines
186+
log_output=$(adb -s "$serial" logcat -d -t 500 2>/dev/null || true)
187+
188+
# Check for Metro connection errors (these appear in red box)
189+
if echo "$log_output" | grep -qi "unable.*load.*script\|could.*not.*connect.*metro\|connection.*refused.*8081\|packaged.*correctly.*for.*release"; then
187190
echo "ERROR: App cannot connect to Metro bundler:" >&2
188-
echo "$log_output" | grep -iE "unable|load|script|connect|metro|refused|8081" | tail -20 >&2
191+
echo "$log_output" | grep -iE "unable|load|script|connect|metro|refused|8081|packaged|release|bundle" | tail -30 >&2
192+
echo "" >&2
193+
echo "Full recent logs:" >&2
194+
echo "$log_output" | tail -50 >&2
189195
exit 1
190196
fi
191197
192198
# Check for other fatal errors
193199
if echo "$log_output" | grep -qi "fatal.*error\|exception.*error"; then
194200
echo "ERROR: App encountered fatal errors:" >&2
195-
echo "$log_output" | grep -iE "fatal|exception" | tail -15 >&2
201+
echo "$log_output" | grep -iE "fatal|exception" | tail -20 >&2
196202
exit 1
197203
fi
198204

0 commit comments

Comments
 (0)