Improve DX for FBReactKitIntegrationTests
Summary: - Enable logging so `console.log` shows up in Xcode console (and CI?) - Allow loading from bundler for rapid JS iteration. - Add option to enable JS debugging, although it's a little ghetto. Reviewed By: mmmulani Differential Revision: D5869085 fbshipit-source-id: 9c4831859f1491f7f75786f730d8549d69623888
This commit is contained in:
parent
f7f347329e
commit
af2e3fea1b
|
@ -50,6 +50,10 @@
|
|||
*/
|
||||
@property (nonatomic, assign) BOOL recordMode;
|
||||
|
||||
@property (nonatomic, assign, readwrite) BOOL useBundler;
|
||||
|
||||
@property (nonatomic, assign, readwrite) BOOL useJSDebugger;
|
||||
|
||||
@property (nonatomic, copy) NSString *testSuffix;
|
||||
|
||||
@property (nonatomic, readonly) NSURL *scriptURL;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#import <React/RCTAssert.h>
|
||||
#import <React/RCTBridge+Private.h>
|
||||
#import <React/RCTDevSettings.h>
|
||||
#import <React/RCTLog.h>
|
||||
#import <React/RCTRootView.h>
|
||||
#import <React/RCTUtils.h>
|
||||
|
@ -24,6 +25,7 @@ static const NSTimeInterval kTestTimeoutSeconds = 120;
|
|||
{
|
||||
FBSnapshotTestController *_testController;
|
||||
RCTBridgeModuleListProvider _moduleProvider;
|
||||
NSString *_appPath;
|
||||
}
|
||||
|
||||
- (instancetype)initWithApp:(NSString *)app
|
||||
|
@ -43,19 +45,24 @@ static const NSTimeInterval kTestTimeoutSeconds = 120;
|
|||
_testController = [[FBSnapshotTestController alloc] initWithTestName:sanitizedAppName];
|
||||
_testController.referenceImagesDirectory = referenceDirectory;
|
||||
_moduleProvider = [block copy];
|
||||
|
||||
if (getenv("CI_USE_PACKAGER")) {
|
||||
_scriptURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=ios&dev=true", app]];
|
||||
} else {
|
||||
_scriptURL = [[NSBundle bundleForClass:[RCTBridge class]] URLForResource:@"main" withExtension:@"jsbundle"];
|
||||
}
|
||||
RCTAssert(_scriptURL != nil, @"No scriptURL set");
|
||||
_appPath = app;
|
||||
[self updateScript];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
|
||||
- (void)updateScript
|
||||
{
|
||||
if (getenv("CI_USE_PACKAGER") || _useBundler) {
|
||||
_scriptURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=ios&dev=true", _appPath]];
|
||||
} else {
|
||||
_scriptURL = [[NSBundle bundleForClass:[RCTBridge class]] URLForResource:@"main" withExtension:@"jsbundle"];
|
||||
}
|
||||
RCTAssert(_scriptURL != nil, @"No scriptURL set");
|
||||
}
|
||||
|
||||
- (void)setRecordMode:(BOOL)recordMode
|
||||
{
|
||||
_testController.recordMode = recordMode;
|
||||
|
@ -66,6 +73,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|||
return _testController.recordMode;
|
||||
}
|
||||
|
||||
- (void)setUseBundler:(BOOL)useBundler
|
||||
{
|
||||
_useBundler = useBundler;
|
||||
[self updateScript];
|
||||
}
|
||||
|
||||
- (void)runTest:(SEL)test module:(NSString *)moduleName
|
||||
{
|
||||
[self runTest:test module:moduleName initialProps:nil configurationBlock:nil expectErrorBlock:nil];
|
||||
|
@ -110,9 +123,9 @@ expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock
|
|||
RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:_scriptURL
|
||||
moduleProvider:_moduleProvider
|
||||
launchOptions:nil];
|
||||
[bridge.devSettings setIsDebuggingRemotely:_useJSDebugger];
|
||||
batchedBridge = [bridge batchedBridge];
|
||||
|
||||
|
||||
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:moduleName initialProperties:initialProps];
|
||||
#if TARGET_OS_TV
|
||||
rootView.frame = CGRectMake(0, 0, 1920, 1080); // Standard screen size for tvOS
|
||||
|
|
Loading…
Reference in New Issue