Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gate Platform.isTesting via __DEV__ on the native level #38339

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions packages/react-native/Libraries/Utilities/Platform.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 2 additions & 5 deletions packages/react-native/Libraries/Utilities/Platform.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/CoreModules/RCTPlatform.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down