Permalink
Browse files

Pass scriptURL to RCTTestRunner

Summary:
Pass scriptURL to RCTTestRunner.
If the scriptURL passed to RCTTestRunner is not nil, then RCTTestRunner will use it.
else, RCTTestRunner will use whatever it has before.

Differential Revision: D6215186

fbshipit-source-id: c3a5643021d60579fc8e60a69de150f6a4a39237
  • Loading branch information...
Chris Zheng authored and facebook-github-bot committed Nov 12, 2017
1 parent d79e245 commit 266ab7a0061c11c4da7ccde9e0d461c0d7331563
@@ -32,10 +32,11 @@
* Use the RCTInitRunnerForApp macro for typical usage. See FBSnapshotTestCase.h for more information
* on how to configure the snapshotting system.
*/
#define RCTInitRunnerForApp(app__, moduleProvider__) \
#define RCTInitRunnerForApp(app__, moduleProvider__, scriptURL__) \
[[RCTTestRunner alloc] initWithApp:(app__) \
referenceDirectory:@FB_REFERENCE_IMAGE_DIR \
moduleProvider:(moduleProvider__)]
moduleProvider:(moduleProvider__) \
scriptURL: scriptURL__]
@protocol RCTBridgeModule;
@class RCTBridge;
@@ -68,7 +69,8 @@
*/
- (instancetype)initWithApp:(NSString *)app
referenceDirectory:(NSString *)referenceDirectory
moduleProvider:(RCTBridgeModuleListProvider)block NS_DESIGNATED_INITIALIZER;
moduleProvider:(RCTBridgeModuleListProvider)block
scriptURL:(NSURL *)scriptURL NS_DESIGNATED_INITIALIZER;
/**
* Simplest runTest function simply mounts the specified JS module with no
@@ -31,6 +31,7 @@ @implementation RCTTestRunner
- (instancetype)initWithApp:(NSString *)app
referenceDirectory:(NSString *)referenceDirectory
moduleProvider:(RCTBridgeModuleListProvider)block
scriptURL:(NSURL *)scriptURL
{
RCTAssertParam(app);
RCTAssertParam(referenceDirectory);
@@ -46,7 +47,12 @@ - (instancetype)initWithApp:(NSString *)app
_testController.referenceImagesDirectory = referenceDirectory;
_moduleProvider = [block copy];
_appPath = app;
[self updateScript];
if (scriptURL != nil) {
_scriptURL = scriptURL;
} else {
[self updateScript];
}
}
return self;
}
@@ -117,7 +117,7 @@ @implementation RCTRootViewIntegrationTests
- (void)setUp
{
_runner = RCTInitRunnerForApp(@"IntegrationTests/RCTRootViewIntegrationTestApp", nil);
_runner = RCTInitRunnerForApp(@"IntegrationTests/RCTRootViewIntegrationTestApp", nil, nil);
}
#pragma mark Logic Tests
@@ -37,7 +37,7 @@ @implementation RNTesterIntegrationTests
- (void)setUp
{
_runner = RCTInitRunnerForApp(@"IntegrationTests/IntegrationTestsApp", nil);
_runner = RCTInitRunnerForApp(@"IntegrationTests/IntegrationTestsApp", nil, nil);
_runner.recordMode = NO;
}
@@ -24,7 +24,7 @@ @implementation RNTesterSnapshotTests
- (void)setUp
{
_runner = RCTInitRunnerForApp(@"RNTester/js/RNTesterApp.ios", nil);
_runner = RCTInitRunnerForApp(@"RNTester/js/RNTesterApp.ios", nil, nil);
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 11) {
_runner.testSuffix = @"-iOS11";
} else if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10) {

0 comments on commit 266ab7a

Please sign in to comment.