diff --git a/packages/react-native/Libraries/Utilities/Platform.android.js b/packages/react-native/Libraries/Utilities/Platform.android.js index 29234be81a7baa..f9753e62be7dbb 100644 --- a/packages/react-native/Libraries/Utilities/Platform.android.js +++ b/packages/react-native/Libraries/Utilities/Platform.android.js @@ -54,11 +54,8 @@ const Platform = { }, // $FlowFixMe[unsafe-getters-setters] get isTesting(): boolean { - if (__DEV__) { - // $FlowFixMe[object-this-reference] - return this.constants.isTesting; - } - return false; + // $FlowFixMe[object-this-reference] + return this.constants.isTesting; }, // $FlowFixMe[unsafe-getters-setters] get isTV(): boolean { diff --git a/packages/react-native/Libraries/Utilities/Platform.ios.js b/packages/react-native/Libraries/Utilities/Platform.ios.js index 4adf4201c52b3e..9847e3cdb9e4c7 100644 --- a/packages/react-native/Libraries/Utilities/Platform.ios.js +++ b/packages/react-native/Libraries/Utilities/Platform.ios.js @@ -59,11 +59,8 @@ const Platform = { }, // $FlowFixMe[unsafe-getters-setters] get isTesting(): boolean { - if (__DEV__) { - // $FlowFixMe[object-this-reference] - return this.constants.isTesting; - } - return false; + // $FlowFixMe[object-this-reference] + return this.constants.isTesting; }, select: (spec: PlatformSelectSpec): T => // $FlowFixMe[incompatible-return] diff --git a/packages/react-native/React/CoreModules/RCTPlatform.mm b/packages/react-native/React/CoreModules/RCTPlatform.mm index 7c76ffb1f8a32c..f062a93f203ec2 100644 --- a/packages/react-native/React/CoreModules/RCTPlatform.mm +++ b/packages/react-native/React/CoreModules/RCTPlatform.mm @@ -69,7 +69,7 @@ - (dispatch_queue_t)methodQueue .osVersion = [device systemVersion], .systemName = [device systemName], .interfaceIdiom = interfaceIdiom([device userInterfaceIdiom]), - .isTesting = RCTRunningInTestEnvironment() ? true : false, + .isTesting = (RCT_DEV && RCTRunningInTestEnvironment()) ? true : false, .reactNativeVersion = JS::NativePlatformConstantsIOS::ConstantsReactNativeVersion::Builder( {.minor = [versions[@"minor"] doubleValue], .major = [versions[@"major"] doubleValue], diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoModule.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoModule.java index 8a3fe903b5a0d2..866f0c7a73e9b3 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoModule.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoModule.java @@ -28,6 +28,7 @@ @SuppressLint("HardwareIds") public class AndroidInfoModule extends NativePlatformConstantsAndroidSpec implements TurboModule { private static final String IS_TESTING = "IS_TESTING"; + private static final boolean DEV = ReactBuildConfig.DEBUG; public AndroidInfoModule(ReactApplicationContext reactContext) { super(reactContext); @@ -74,7 +75,8 @@ private String uiMode() { AndroidInfoHelpers.getServerHost(getReactApplicationContext().getApplicationContext())); } constants.put( - "isTesting", "true".equals(System.getProperty(IS_TESTING)) || isRunningScreenshotTest()); + "isTesting", + DEV && ("true".equals(System.getProperty(IS_TESTING)) || isRunningScreenshotTest())); constants.put("reactNativeVersion", ReactNativeVersion.VERSION); constants.put("uiMode", uiMode()); return constants;