Readme · Guides · Reference · Contributing
Warning
The Optimization SDK Suite is pre-release (alpha). Breaking changes may be published at any time.
This is a reference implementation for the Optimization React Native SDK and is part of the Contentful Optimization SDK Suite.
All steps should be run from the monorepo root.
-
Install pnpm packages:
pnpm install
-
Build and package SDK tarballs used by this implementation:
pnpm run build:pkgs
-
Install implementation dependencies:
pnpm --dir implementations/react-native-sdk --ignore-workspace install --no-frozen-lockfile
-
Ensure an Android emulator is available and running.
See implementations/react-native-sdk/package.json for more commands.
You can run this implementation from the monorepo root via the root package.json implementation
scripts.
-
Run the full Android E2E flow:
pnpm run implementation:react-native-sdk -- test:e2e:android:full
-
Build Android Detox binaries:
pnpm run implementation:react-native-sdk -- test:e2e:android:build
-
Run Android Detox tests only:
pnpm run implementation:react-native-sdk -- test:e2e:android:run
-
Pass script arguments through to the one-shot runner:
pnpm run implementation:react-native-sdk -- test:e2e:android:full -- --test-file e2e/offline-behavior.test.js
Android E2E tests use Detox.
-
Run the one-shot Android E2E flow:
pnpm --dir implementations/react-native-sdk --ignore-workspace test:e2e:android:full
This command:
- creates
.envfrom.env.examplefor E2E - starts the mock server and Metro
- configures adb reverse
- builds the Android app (unless skipped)
- runs Detox tests
- cleans up background processes
- creates
-
Useful one-shot variants:
# Skip rebuild if app is already built SKIP_BUILD=true pnpm --dir implementations/react-native-sdk --ignore-workspace test:e2e:android:full # Run one test file pnpm --dir implementations/react-native-sdk --ignore-workspace test:e2e:android:full -- --test-file e2e/offline-behavior.test.js # Run tests matching a name pattern pnpm --dir implementations/react-native-sdk --ignore-workspace test:e2e:android:full -- -t "should recover gracefully when network is restored"
-
Run Detox steps manually if needed:
pnpm --dir implementations/react-native-sdk --ignore-workspace test:e2e:android:build pnpm --dir implementations/react-native-sdk --ignore-workspace test:e2e:android:run
-
iOS commands:
pnpm --dir implementations/react-native-sdk --ignore-workspace test:e2e:ios:build pnpm --dir implementations/react-native-sdk --ignore-workspace test:e2e:ios:run
Local Android E2E logging is intentionally minimal by default.
-
Enable script/service logs (Metro, mock server, and adb logcat stream):
STREAM_BACKGROUND_LOGS=true ENABLE_DEVICE_LOGCAT=true METRO_VERBOSE=true pnpm --dir implementations/react-native-sdk --ignore-workspace test:e2e:android:full
-
Increase Detox runner logging and artifacts:
pnpm --dir implementations/react-native-sdk --ignore-workspace exec detox test --configuration android.emu.debug --loglevel trace --record-logs all --take-screenshots failing --record-videos failing
-
Read generated logs:
implementations/react-native-sdk/logs/mock-server.logimplementations/react-native-sdk/logs/metro.logimplementations/react-native-sdk/logs/device.logimplementations/react-native-sdk/logs/test-results.log