diff --git a/.maestro/scripts/run-tests.sh b/.maestro/scripts/run-tests.sh index 358ec7a29..cfc8ab6c2 100755 --- a/.maestro/scripts/run-tests.sh +++ b/.maestro/scripts/run-tests.sh @@ -125,18 +125,35 @@ case "$PLATFORM" in *) echo "Error: --platform is required. (--platform )" >&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 diff --git a/apps/react-native-example/e2e-config.json b/apps/react-native-example/e2e-config.json new file mode 100644 index 000000000..662ff2771 --- /dev/null +++ b/apps/react-native-example/e2e-config.json @@ -0,0 +1,3 @@ +{ + "disableLogBox": false +} diff --git a/apps/react-native-example/index.js b/apps/react-native-example/index.js index 789ba4bd7..bb06da9f4 100644 --- a/apps/react-native-example/index.js +++ b/apps/react-native-example/index.js @@ -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 = () => (