Skip to content

Commit

Permalink
Pass scriptURL to RCTTestRunner
Browse files Browse the repository at this point in the history
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 266ab7a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
8 changes: 5 additions & 3 deletions Libraries/RCTTest/RCTTestRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion Libraries/RCTTest/RCTTestRunner.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ @implementation RCTTestRunner
- (instancetype)initWithApp:(NSString *)app
referenceDirectory:(NSString *)referenceDirectory
moduleProvider:(RCTBridgeModuleListProvider)block
scriptURL:(NSURL *)scriptURL
{
RCTAssertParam(app);
RCTAssertParam(referenceDirectory);
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ @implementation RCTRootViewIntegrationTests

- (void)setUp
{
_runner = RCTInitRunnerForApp(@"IntegrationTests/RCTRootViewIntegrationTestApp", nil);
_runner = RCTInitRunnerForApp(@"IntegrationTests/RCTRootViewIntegrationTestApp", nil, nil);
}

#pragma mark Logic Tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ @implementation RNTesterIntegrationTests

- (void)setUp
{
_runner = RCTInitRunnerForApp(@"IntegrationTests/IntegrationTestsApp", nil);
_runner = RCTInitRunnerForApp(@"IntegrationTests/IntegrationTestsApp", nil, nil);
_runner.recordMode = NO;
}

Expand Down
2 changes: 1 addition & 1 deletion RNTester/RNTesterIntegrationTests/RNTesterSnapshotTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 266ab7a

Please sign in to comment.