diff --git a/Libraries/ReactNative/YellowBox.js b/Libraries/ReactNative/YellowBox.js index a43e7a442..2c0852bab 100644 --- a/Libraries/ReactNative/YellowBox.js +++ b/Libraries/ReactNative/YellowBox.js @@ -70,8 +70,7 @@ if (__DEV__) { updateWarningMap.apply(null, arguments); }; - const ProcessInfo = require('NativeModules').ProcessInfo; - if (ProcessInfo && ProcessInfo.environment.DISABLE_YELLOW_BOX) { + if (Platform.isTesting) { (console: any).disableYellowBox = true; } } diff --git a/Libraries/Utilities/Platform.ios.js b/Libraries/Utilities/Platform.ios.js index b02cac772..9896c88c7 100644 --- a/Libraries/Utilities/Platform.ios.js +++ b/Libraries/Utilities/Platform.ios.js @@ -22,6 +22,10 @@ const Platform = { const constants = require('NativeModules').IOSConstants; return constants ? (constants.interfaceIdiom === 'tv') : false; }, + get isTesting(): boolean { + const constants = require('NativeModules').IOSConstants; + return constants && constants.isTesting; + }, select: (obj: Object) => obj.ios, }; diff --git a/React/Base/RCTPlatform.m b/React/Base/RCTPlatform.m index 61bc69977..766fd3874 100644 --- a/React/Base/RCTPlatform.m +++ b/React/Base/RCTPlatform.m @@ -30,6 +30,11 @@ static NSString *interfaceIdiom(UIUserInterfaceIdiom idiom) { } } +static BOOL isTestingEnvironment(void) { + NSDictionary *environment = [[NSProcessInfo processInfo] environment]; + return [environment[@"IS_TESTING"] boolValue]; +} + RCT_EXPORT_MODULE(IOSConstants) - (NSDictionary *)constantsToExport @@ -40,6 +45,7 @@ RCT_EXPORT_MODULE(IOSConstants) @"osVersion": [device systemVersion], @"systemName": [device systemName], @"interfaceIdiom": interfaceIdiom([device userInterfaceIdiom]), + @"isTesting": @(isTestingEnvironment()), }; } diff --git a/React/Modules/RCTProcessInfo.h b/React/Modules/RCTProcessInfo.h deleted file mode 100644 index f4a501fbe..000000000 --- a/React/Modules/RCTProcessInfo.h +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) 2017-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -#import -#import - -@interface RCTProcessInfo : NSObject - -@end diff --git a/React/Modules/RCTProcessInfo.m b/React/Modules/RCTProcessInfo.m deleted file mode 100644 index bd15c2cf2..000000000 --- a/React/Modules/RCTProcessInfo.m +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2017-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -#import "RCTProcessInfo.h" - -@implementation RCTProcessInfo - -RCT_EXPORT_MODULE() - -- (NSDictionary *)constantsToExport -{ - NSProcessInfo *processInfo = [NSProcessInfo processInfo]; - return - @{ - @"environment": processInfo.environment, - @"arguments": processInfo.arguments, - }; -} - -@end diff --git a/docs/Debugging.md b/docs/Debugging.md index a011eb4ae..8817229cd 100644 --- a/docs/Debugging.md +++ b/docs/Debugging.md @@ -51,7 +51,7 @@ As with a RedBox, you can use `console.warn()` to trigger a YellowBox. YellowBoxes can be disabled during development by using `console.disableYellowBox = true;`. Specific warnings can be ignored programmatically by setting an array of prefixes that should be ignored: `console.ignoredYellowBox = ['Warning: ...'];`. -In CI/Xcode, YellowBoxes can also be disabled by setting the `DISABLE_YELLOW_BOX` environment variable. +In CI/Xcode, YellowBoxes can also be disabled by setting the `IS_TESTING` environment variable. > RedBoxes and YellowBoxes are automatically disabled in release (production) builds.