Skip to content

Commit 266ab7a

Browse files
Chris Zhengfacebook-github-bot
Chris Zheng
authored andcommitted
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
1 parent d79e245 commit 266ab7a

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

Libraries/RCTTest/RCTTestRunner.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@
3232
* Use the RCTInitRunnerForApp macro for typical usage. See FBSnapshotTestCase.h for more information
3333
* on how to configure the snapshotting system.
3434
*/
35-
#define RCTInitRunnerForApp(app__, moduleProvider__) \
35+
#define RCTInitRunnerForApp(app__, moduleProvider__, scriptURL__) \
3636
[[RCTTestRunner alloc] initWithApp:(app__) \
3737
referenceDirectory:@FB_REFERENCE_IMAGE_DIR \
38-
moduleProvider:(moduleProvider__)]
38+
moduleProvider:(moduleProvider__) \
39+
scriptURL: scriptURL__]
3940

4041
@protocol RCTBridgeModule;
4142
@class RCTBridge;
@@ -68,7 +69,8 @@
6869
*/
6970
- (instancetype)initWithApp:(NSString *)app
7071
referenceDirectory:(NSString *)referenceDirectory
71-
moduleProvider:(RCTBridgeModuleListProvider)block NS_DESIGNATED_INITIALIZER;
72+
moduleProvider:(RCTBridgeModuleListProvider)block
73+
scriptURL:(NSURL *)scriptURL NS_DESIGNATED_INITIALIZER;
7274

7375
/**
7476
* Simplest runTest function simply mounts the specified JS module with no

Libraries/RCTTest/RCTTestRunner.m

+7-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ @implementation RCTTestRunner
3131
- (instancetype)initWithApp:(NSString *)app
3232
referenceDirectory:(NSString *)referenceDirectory
3333
moduleProvider:(RCTBridgeModuleListProvider)block
34+
scriptURL:(NSURL *)scriptURL
3435
{
3536
RCTAssertParam(app);
3637
RCTAssertParam(referenceDirectory);
@@ -46,7 +47,12 @@ - (instancetype)initWithApp:(NSString *)app
4647
_testController.referenceImagesDirectory = referenceDirectory;
4748
_moduleProvider = [block copy];
4849
_appPath = app;
49-
[self updateScript];
50+
51+
if (scriptURL != nil) {
52+
_scriptURL = scriptURL;
53+
} else {
54+
[self updateScript];
55+
}
5056
}
5157
return self;
5258
}

RNTester/RNTesterIntegrationTests/RCTRootViewIntegrationTests.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ @implementation RCTRootViewIntegrationTests
117117

118118
- (void)setUp
119119
{
120-
_runner = RCTInitRunnerForApp(@"IntegrationTests/RCTRootViewIntegrationTestApp", nil);
120+
_runner = RCTInitRunnerForApp(@"IntegrationTests/RCTRootViewIntegrationTestApp", nil, nil);
121121
}
122122

123123
#pragma mark Logic Tests

RNTester/RNTesterIntegrationTests/RNTesterIntegrationTests.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ @implementation RNTesterIntegrationTests
3737

3838
- (void)setUp
3939
{
40-
_runner = RCTInitRunnerForApp(@"IntegrationTests/IntegrationTestsApp", nil);
40+
_runner = RCTInitRunnerForApp(@"IntegrationTests/IntegrationTestsApp", nil, nil);
4141
_runner.recordMode = NO;
4242
}
4343

RNTester/RNTesterIntegrationTests/RNTesterSnapshotTests.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ @implementation RNTesterSnapshotTests
2424

2525
- (void)setUp
2626
{
27-
_runner = RCTInitRunnerForApp(@"RNTester/js/RNTesterApp.ios", nil);
27+
_runner = RCTInitRunnerForApp(@"RNTester/js/RNTesterApp.ios", nil, nil);
2828
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 11) {
2929
_runner.testSuffix = @"-iOS11";
3030
} else if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10) {

0 commit comments

Comments
 (0)