mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Gate Platform.isTesting via __DEV__ on the native level (#38339)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38339 ## Changelog: [Internal] - In D13050583, the `Platform.isTesting` was unconditionally forced to `false` in `__DEV__` on JS side. On some platforms, we may want to run tests in the release mode. This hoists these gatings down to the corresponding platforms' native modules. Reviewed By: ryancat Differential Revision: D47438069 fbshipit-source-id: 5bae3df9873f659f65179df93e727108d0062047
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d9c8cd3b40
commit
ecb58a1d85
@@ -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 {
|
||||
|
||||
@@ -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: <T>(spec: PlatformSelectSpec<T>): T =>
|
||||
// $FlowFixMe[incompatible-return]
|
||||
|
||||
@@ -69,7 +69,7 @@ RCT_EXPORT_MODULE(PlatformConstants)
|
||||
.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],
|
||||
|
||||
+3
-1
@@ -28,6 +28,7 @@ import java.util.Map;
|
||||
@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 @@ public class AndroidInfoModule extends NativePlatformConstantsAndroidSpec implem
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user