Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions .maestro/scripts/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,35 @@ case "$PLATFORM" in
*) echo "Error: --platform is required. (--platform <ios|android>)" >&2; exit 1 ;;
esac

SETUP_OUTPUT=$("$SETUP" 2>&1)
echo "$SETUP_OUTPUT"
DEVICE_ID=$(echo "$SETUP_OUTPUT" | grep "^DEVICE_ID=" | cut -d= -f2)
# Suppress the RN example's LogBox for this run so warning overlays never corrupt
# the exact-match (100%) screenshot assertions. The flag file is a bundled source
# input, so the build/Metro picks it up. Only the RN app uses it, so leave the
# native-example apps untouched; the original file bytes are restored on exit.
E2E_FLAG_FILE="$REPO_ROOT/apps/react-native-example/e2e-config.json"
E2E_FLAG_BACKUP=""
if [ "$APP" = "rn" ]; then
E2E_FLAG_BACKUP="$(mktemp)"
cp "$E2E_FLAG_FILE" "$E2E_FLAG_BACKUP"
node -e 'const f=process.argv[1],fs=require("fs");const c=JSON.parse(fs.readFileSync(f,"utf8"));c.disableLogBox=true;fs.writeFileSync(f,JSON.stringify(c,null,2)+"\n");' "$E2E_FLAG_FILE"
fi

shutdown_device() {
if [ "$PLATFORM" = ios ]; then
xcrun simctl shutdown "$DEVICE_ID" 2>/dev/null || true
else
adb -s "$DEVICE_ID" emu kill 2>/dev/null || true
cleanup() {
if [ -n "$E2E_FLAG_BACKUP" ] && [ -f "$E2E_FLAG_BACKUP" ]; then
mv "$E2E_FLAG_BACKUP" "$E2E_FLAG_FILE"
fi
if [ -n "${DEVICE_ID:-}" ]; then
if [ "$PLATFORM" = ios ]; then
xcrun simctl shutdown "$DEVICE_ID" 2>/dev/null || true
else
adb -s "$DEVICE_ID" emu kill 2>/dev/null || true
fi
fi
}
trap shutdown_device EXIT
trap cleanup EXIT

SETUP_OUTPUT=$("$SETUP" 2>&1)
echo "$SETUP_OUTPUT"
DEVICE_ID=$(echo "$SETUP_OUTPUT" | grep "^DEVICE_ID=" | cut -d= -f2)

app_installed() {
if [ "$PLATFORM" = ios ]; then
Expand Down
3 changes: 3 additions & 0 deletions apps/react-native-example/e2e-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"disableLogBox": false
}
7 changes: 6 additions & 1 deletion apps/react-native-example/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { AppRegistry } from 'react-native';
import { AppRegistry, LogBox } from 'react-native';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import App from './src/App';
import { name as appName } from './app.json';
import e2eConfig from './e2e-config.json';

if (e2eConfig.disableLogBox) {
LogBox.ignoreAllLogs();
}

const Root = () => (
<SafeAreaProvider>
Expand Down
Loading