Switch out DISABLE_YELLOW_BOX for IS_TESTING
Summary: Switch to using IS_TESTING on the Platform module. While IS_TESTING has to be explicitly set in the test harness, this makes it more usable and stops people from relying on brittle variables in the (larger) environment. Reviewed By: fkgozali Differential Revision: D4423661 fbshipit-source-id: 27a80867778b9374bcba67b69f9c93d32c0a74b0
This commit is contained in:
parent
a4bfac907e
commit
81c33b542d
|
@ -70,8 +70,7 @@ if (__DEV__) {
|
||||||
updateWarningMap.apply(null, arguments);
|
updateWarningMap.apply(null, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
const ProcessInfo = require('NativeModules').ProcessInfo;
|
if (Platform.isTesting) {
|
||||||
if (ProcessInfo && ProcessInfo.environment.DISABLE_YELLOW_BOX) {
|
|
||||||
(console: any).disableYellowBox = true;
|
(console: any).disableYellowBox = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,10 @@ const Platform = {
|
||||||
const constants = require('NativeModules').IOSConstants;
|
const constants = require('NativeModules').IOSConstants;
|
||||||
return constants ? (constants.interfaceIdiom === 'tv') : false;
|
return constants ? (constants.interfaceIdiom === 'tv') : false;
|
||||||
},
|
},
|
||||||
|
get isTesting(): boolean {
|
||||||
|
const constants = require('NativeModules').IOSConstants;
|
||||||
|
return constants && constants.isTesting;
|
||||||
|
},
|
||||||
select: (obj: Object) => obj.ios,
|
select: (obj: Object) => obj.ios,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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)
|
RCT_EXPORT_MODULE(IOSConstants)
|
||||||
|
|
||||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||||
|
@ -40,6 +45,7 @@ RCT_EXPORT_MODULE(IOSConstants)
|
||||||
@"osVersion": [device systemVersion],
|
@"osVersion": [device systemVersion],
|
||||||
@"systemName": [device systemName],
|
@"systemName": [device systemName],
|
||||||
@"interfaceIdiom": interfaceIdiom([device userInterfaceIdiom]),
|
@"interfaceIdiom": interfaceIdiom([device userInterfaceIdiom]),
|
||||||
|
@"isTesting": @(isTestingEnvironment()),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 <React/RCTBridge.h>
|
|
||||||
#import <React/RCTBridgeModule.h>
|
|
||||||
|
|
||||||
@interface RCTProcessInfo : NSObject <RCTBridgeModule>
|
|
||||||
|
|
||||||
@end
|
|
|
@ -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
|
|
|
@ -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: ...'];`.
|
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.
|
> RedBoxes and YellowBoxes are automatically disabled in release (production) builds.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue