iamolegga / react-native-launch-arguments

Get launch arguments for testing with Detox and Appium
MIT License
55 stars 21 forks source link
appium detox react-native testing

react-native-launch-arguments

React Native module to get launch arguments.

Makes passing parameters from testing libraries and debugs tools to react-native super easy.

Install

npm i react-native-launch-arguments
cd ios && pod install && cd ..

Usage

In you code

Javascript

import { LaunchArguments } from "react-native-launch-arguments";
LaunchArguments.value();

Typescript

import { LaunchArguments } from "react-native-launch-arguments";
interface MyExpectedArgs {
  authToken?: string;
  skipAuth?: boolean;
}
LaunchArguments.value<MyExpectedArgs>();

Integrating with End-to-end testing tools and debuggers

The intended use is with end-to-end tools like Detox.

Detox

Appium

Maestro

XCode

Platform-specific Notes

iOS

It takes data from [[NSProcessInfo processInfo] arguments]

Verifying install on iPhone simulator

You can use xcrun to boot your app on the simulator.

The following command-line will load your app on the booted iOS simulator. Just replace com.MyAppBundleId with your Bundle Identifier, and the params with your params.

xcrun simctl launch booted com.MyAppBundleId -noParams -param "hello"

Android

It takes data from currentActivity.getIntent().getBundleExtra("launchArgs") for detox and intent.getExtras() for ADB params

Caveats on Android

Due to React Native issue #37518, on Android, the module force-waits for the Android activity to reach the RESUMED state, before moving foward with native-modules initialization completion. While commonly the wait is scarce (the activity is already in the resumed state at this point), until the RN issue is fixed, the module may introduce delays in app loading time in some edge cases.