diff --git a/Libraries/RCTTest/RCTTestRunner.h b/Libraries/RCTTest/RCTTestRunner.h index c59f73d73..b1edad6a2 100644 --- a/Libraries/RCTTest/RCTTestRunner.h +++ b/Libraries/RCTTest/RCTTestRunner.h @@ -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; diff --git a/Libraries/RCTTest/RCTTestRunner.m b/Libraries/RCTTest/RCTTestRunner.m index dd381c0da..cb79087c3 100644 --- a/Libraries/RCTTest/RCTTestRunner.m +++ b/Libraries/RCTTest/RCTTestRunner.m @@ -11,6 +11,7 @@ #import #import +#import #import #import #import @@ -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