mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-13 12:26:45 +08:00
Set Platform.isTesting true when running Server Snapshot Tests
Summary: `Platform.isTesting` returns false when running SSTs. This diff changes that to true. See https://our.intern.facebook.com/intern/qa/9690/how-to-detect-when-running-as-sst for inspiration. I fixed this for iOS in D13981728. Reviewed By: cpojer Differential Revision: D14244606 fbshipit-source-id: ed95b772cc4206cf7c835aed7415aa5fc5fbdf7d
This commit is contained in:
committed by
Facebook Github Bot
parent
0ae48f5c38
commit
f2d20d2904
@@ -76,7 +76,8 @@ public class AndroidInfoModule extends ReactContextBaseJavaModule {
|
||||
if (ReactBuildConfig.DEBUG) {
|
||||
constants.put("ServerHost", AndroidInfoHelpers.getServerHost());
|
||||
}
|
||||
constants.put("isTesting", "true".equals(System.getProperty(IS_TESTING)));
|
||||
constants.put("isTesting", "true".equals(System.getProperty(IS_TESTING))
|
||||
|| isRunningScreenshotTest());
|
||||
constants.put("reactNativeVersion", ReactNativeVersion.VERSION);
|
||||
constants.put("uiMode", uiMode());
|
||||
return constants;
|
||||
@@ -86,4 +87,13 @@ public class AndroidInfoModule extends ReactContextBaseJavaModule {
|
||||
public String getAndroidID(){
|
||||
return Secure.getString(getReactApplicationContext().getContentResolver(),Secure.ANDROID_ID);
|
||||
}
|
||||
|
||||
private Boolean isRunningScreenshotTest() {
|
||||
try {
|
||||
Class.forName("android.support.test.rule.ActivityTestRule");
|
||||
return true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user