From a027218641acae5317a8dac1b2025216e41674f7 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Wed, 18 Nov 2015 08:25:30 -0800 Subject: [PATCH] Move JS integration tests to root folder Reviewed By: mkonicek Differential Revision: D2658454 fb-gh-sync-id: b639ea995411a7e43903264318b5fca4d2f1e9f7 --- .../testSimpleSnapshotTest_1@2x.png | Bin 57703 -> 0 bytes .../testImageSnapshotTest_1@2x.png | Bin .../testSimpleSnapshotTest_1@2x.png | Bin 0 -> 15597 bytes .../UIExplorerIntegrationTests.m | 11 ++++----- .../js => IntegrationTests}/AppEventsTest.js | 3 +-- .../AsyncStorageTest.js | 16 +++++++------ .../ImageSnapshotTest.js | 7 +++--- .../IntegrationTestHarnessTest.js | 11 +++++---- .../IntegrationTestsApp.js | 7 ++---- .../LayoutEventsTest.js | 3 +-- .../js => IntegrationTests}/PromiseTest.js | 21 +++++++++--------- .../SimpleSnapshotTest.js | 9 +++++--- .../js => IntegrationTests}/TimersTest.js | 14 ++++++++---- Libraries/RCTTest/RCTTestRunner.h | 8 ++++++- 14 files changed, 63 insertions(+), 47 deletions(-) delete mode 100644 Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerIntegrationTests-js-IntegrationTestsApp/testSimpleSnapshotTest_1@2x.png rename Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/{Examples-UIExplorer-UIExplorerIntegrationTests-js-IntegrationTestsApp => IntegrationTests-IntegrationTestsApp}/testImageSnapshotTest_1@2x.png (100%) create mode 100644 Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/IntegrationTests-IntegrationTestsApp/testSimpleSnapshotTest_1@2x.png rename {Examples/UIExplorer/UIExplorerIntegrationTests/js => IntegrationTests}/AppEventsTest.js (96%) rename {Examples/UIExplorer/UIExplorerIntegrationTests/js => IntegrationTests}/AsyncStorageTest.js (93%) rename {Examples/UIExplorer/UIExplorerIntegrationTests/js => IntegrationTests}/ImageSnapshotTest.js (91%) rename {Examples/UIExplorer/UIExplorerIntegrationTests/js => IntegrationTests}/IntegrationTestHarnessTest.js (84%) rename {Examples/UIExplorer/UIExplorerIntegrationTests/js => IntegrationTests}/IntegrationTestsApp.js (94%) rename {Examples/UIExplorer/UIExplorerIntegrationTests/js => IntegrationTests}/LayoutEventsTest.js (98%) rename {Examples/UIExplorer/UIExplorerIntegrationTests/js => IntegrationTests}/PromiseTest.js (80%) rename {Examples/UIExplorer/UIExplorerIntegrationTests/js => IntegrationTests}/SimpleSnapshotTest.js (89%) rename {Examples/UIExplorer/UIExplorerIntegrationTests/js => IntegrationTests}/TimersTest.js (95%) diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerIntegrationTests-js-IntegrationTestsApp/testSimpleSnapshotTest_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerIntegrationTests-js-IntegrationTestsApp/testSimpleSnapshotTest_1@2x.png deleted file mode 100644 index fd91abf4238eeef539800f9c8ca71eb398fb1881..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 57703 zcmeHQd0bQ1wm#>0kVI4hsMv}nD1+7tI8;z590f%xidrw#N(Dqq>$8X>ScaT9fz^sL zwu(^ON(U9ZdIb?7b-qP`S}VND5Jj9&f}#c_BzJ|qp|{Cj_mB6-dvE#sDU!3Z&)VN! z>)YR6dnIS{%o#y_dcEF@VVFL_Qv+u+3@0*-b+)7@yt3rf(cj?*yK;8WB<5I|!$bH* z8aH*`N`@KWV*JYn&vtHx7acwc44nf%Irs~IEGyujVdSUr|DV-=E1b1v7=Z~6oH!?e zeO#s77JYihr?U)(P;J%XZ=(`Nm!`Tr-06F~XTpOom+V~?ZSi}2ea90ILx9Mz950c{ zJ>OL?`{wZ5Z;{^wQ5C^exX1-^xwoB6JU<{dytAbsip(lYcuVKS^E|K4+c+qLb|YtM zx_j_sS?{H{FS*c8Btm@m%|ZmG@BD)0Q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a**;P!OOXKtb>y z9-@BeaEE1>3EvpM3johzjfc?i*%Cam#^ZUcV!(?n8$5ai5M7uC}2sU|i_2Zip;WY_2sy*Y9+-s0$Qrt>^zz1ja#PC z-#wX*uAb$tk<6uD_FYf3j$~fZTZ%%6irL!V9Uj!xX@ZJ*-h*1F+$XXFM}&7jAe(*A z{ebLIY!A<{f`YDL^r*0=9?LJ}dPW|J>wXA!&um8=5Y7-NJ9Ie+1QBBh7zs%MxE4tP zNr9}NND4;1f~0_?Kr|>S1yl-jJAtHtq=2M=TX4)N$S~^zYXYXRjHiT{mxDC{6OFKY zL{dOfpr__Y3P=igK7QjX@*fDL7~(Bn2b|tR%tG7_9YSIV@g+ zLj^1^gMBmB%fXs}1%Sr#10)3`1#;4eq=2MA%MXwgkQ9&<@S_4)x83>K6RgI-8lzPwWgkA9pum(NM%9fUzN@FZ7x2i3ekzm^lPaEK1> z17k)L{QxmQKQQWa^aI2I{h;gX+i_h$K0rP|K0rRey))(yFo$BAN8(B>tJm8$-JK4J PCnk9EjKE`)BG>&3nXO8> diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerIntegrationTests-js-IntegrationTestsApp/testImageSnapshotTest_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/IntegrationTests-IntegrationTestsApp/testImageSnapshotTest_1@2x.png similarity index 100% rename from Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerIntegrationTests-js-IntegrationTestsApp/testImageSnapshotTest_1@2x.png rename to Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/IntegrationTests-IntegrationTestsApp/testImageSnapshotTest_1@2x.png diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/IntegrationTests-IntegrationTestsApp/testSimpleSnapshotTest_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/IntegrationTests-IntegrationTestsApp/testSimpleSnapshotTest_1@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..ea37dc900f3d571e79bcccb7402f1039cd9ffe03 GIT binary patch literal 15597 zcmeI3F=!M)6o%h!)^J7-Pb>^J9@togU~RGL1#?XhwGbqDqDE0siFeU*NheqerZYiX z(+HwTp|KYPF^UMLk|3gp2JCd-!NRi4o7sQ3jK{KR0yBIwv-AG{y|=l`onsS6t3!K+ zh^X2eZyYD`BcdJimBD!A^3%uf;$J)4W2f3Du1~dZot?fwH?CbgH{H2;DeN?V5gokW zY#cgy`{TFOm1;Cv8(3NX{rSmT-+vSw*!SFfF%wYq@UBm5`~4b)M50LZYA^ z?^Yx7Dil$mniht8PsvBn?S)hN$CdVSMVSMlIw4Nw3x0MloT^151gI_95YuQb>ea~7 z>(#2l0Hwma0TLCywy^l&!TXJ`oGf~ESAU+J|KX(E01L{M_i#VhxyX*n z7yNAD#wonyvEXp3f8KrnYjbYl2Rj$pQAP6}?gzUHW=G*Jvh|*u@>-`!>f^fS%zLg} zRCbScesD?Q?Iz0uwn<$g&7YT~hOcnmE4#-cx~Sj1r|ey`F9Dh4!EwT}Lqu&) zGIII_JiD^1y64J!W%p?32RjPWXre<`R95Txw1HFZ3gx;_hRmUwE}HjTy@Rn5@Vzpr zTon+-qBvDF7jbszXYYyMFiO&zDh=S})qk^vbSnx;Oc*xE3a1p(%@H)5G8|l(7KRNc z#HpfrPbFQmHk?toi&$_t<*ZPaACPl&T)D_@FGJE0riEdR7z^j3KKGvS8^fyVYfgq) zs{DYQ_)2g;xTFf_Jy#WsTPA!j+(ld>a0+iXS*AEuen3tf9SavtEqBH#{;9A3y>e!* zHQOAhP%Do0XsoN@kZ60IXfXc2j(9lo0(u#TN0=6dHI!zto>H2{G|y#0nJ-DTs4FU8 z7_%qDsr-^j?}byt;Z{VS$!3_U?J3+rycbU4zGKn5qDqf<(`e~&7F_A^ZV@d#&MgI= y8IoL#= 3) || version.majorVersion >= 9, @"Tests should be run on iOS 8.3+, found %zd.%zd.%zd", version.majorVersion, version.minorVersion, version.patchVersion); - _runner = RCTInitRunnerForApp(@"Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp", nil); + _runner = RCTInitRunnerForApp(@"IntegrationTests/IntegrationTestsApp", nil); } -#pragma mark Logic Tests +#pragma mark - Test harness - (void)testTheTester_waitOneFrame { @@ -59,16 +59,17 @@ configurationBlock:nil expectErrorRegex:@"because shouldThrow"]; } +#pragma mark - JS tests + // This list should be kept in sync with IntegrationTestsApp.js RCT_TEST(IntegrationTestHarnessTest) RCT_TEST(TimersTest) RCT_TEST(AsyncStorageTest) RCT_TEST(AppEventsTest) //RCT_TEST(ImageSnapshotTest) // Disabled: #8985988 +//RCT_TEST(LayoutEventsTest) // Disabled due to flakiness: #8686784 RCT_TEST(SimpleSnapshotTest) +RCT_TEST(PromiseTest) -// Disable due to flakiness: #8686784 -//RCT_TEST(LayoutEventsTest) -//RCT_TEST(PromiseTest) @end diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/js/AppEventsTest.js b/IntegrationTests/AppEventsTest.js similarity index 96% rename from Examples/UIExplorer/UIExplorerIntegrationTests/js/AppEventsTest.js rename to IntegrationTests/AppEventsTest.js index 95370771b..7362072ff 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/js/AppEventsTest.js +++ b/IntegrationTests/AppEventsTest.js @@ -14,12 +14,11 @@ var React = require('react-native'); var { NativeAppEventEmitter, - NativeModules, StyleSheet, Text, View, } = React; -var TestModule = NativeModules.TestModule; +var { TestModule } = React.NativeModules; var deepDiffer = require('deepDiffer'); diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/js/AsyncStorageTest.js b/IntegrationTests/AsyncStorageTest.js similarity index 93% rename from Examples/UIExplorer/UIExplorerIntegrationTests/js/AsyncStorageTest.js rename to IntegrationTests/AsyncStorageTest.js index 43df4df18..3bd313a7f 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/js/AsyncStorageTest.js +++ b/IntegrationTests/AsyncStorageTest.js @@ -5,16 +5,18 @@ * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. + * + * @flow */ 'use strict'; -var RCTTestModule = require('NativeModules').TestModule; var React = require('react-native'); var { AsyncStorage, Text, View, } = React; +var { TestModule } = React.NativeModules; var deepDiffer = require('deepDiffer'); @@ -31,21 +33,21 @@ var VAL_MERGE_EXPECT = {'foo': 1, 'bar': {'hoo': 2, 'boo': 1}, 'baz': 2, 'moo': {'a': 3}}; // setup in componentDidMount -var done; -var updateMessage; +var done = (result : ?boolean) => {}; +var updateMessage = (message : string ) => {}; -function runTestCase(description, fn) { +function runTestCase(description : string, fn) { updateMessage(description); fn(); } -function expectTrue(condition, message) { +function expectTrue(condition : boolean, message : string) { if (!condition) { throw new Error(message); } } -function expectEqual(lhs, rhs, testname) { +function expectEqual(lhs, rhs, testname : string) { expectTrue( !deepDiffer(lhs, rhs), 'Error in test ' + testname + ': expected\n' + JSON.stringify(rhs) + @@ -155,7 +157,7 @@ var AsyncStorageTest = React.createClass({ }, componentDidMount() { - done = () => this.setState({done: true}, RCTTestModule.markTestCompleted); + done = () => this.setState({done: true}, TestModule.markTestCompleted); updateMessage = (msg) => { this.setState({messages: this.state.messages.concat('\n' + msg)}); DEBUG && console.log(msg); diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/js/ImageSnapshotTest.js b/IntegrationTests/ImageSnapshotTest.js similarity index 91% rename from Examples/UIExplorer/UIExplorerIntegrationTests/js/ImageSnapshotTest.js rename to IntegrationTests/ImageSnapshotTest.js index 13689742e..7724ab5d3 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/js/ImageSnapshotTest.js +++ b/IntegrationTests/ImageSnapshotTest.js @@ -5,6 +5,8 @@ * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. + * + * @flow */ 'use strict'; @@ -13,8 +15,7 @@ var { Image, View, } = React; - -var { TestModule } = React.addons; +var { TestModule } = React.NativeModules; var ImageSnapshotTest = React.createClass({ componentDidMount() { @@ -23,7 +24,7 @@ var ImageSnapshotTest = React.createClass({ } }, - done(success) { + done(success : boolean) { TestModule.markTestPassed(success); }, diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestHarnessTest.js b/IntegrationTests/IntegrationTestHarnessTest.js similarity index 84% rename from Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestHarnessTest.js rename to IntegrationTests/IntegrationTestHarnessTest.js index 12243a0fe..27ef7428d 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestHarnessTest.js +++ b/IntegrationTests/IntegrationTestHarnessTest.js @@ -5,15 +5,18 @@ * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. + * + * @flow */ 'use strict'; -var RCTTestModule = require('NativeModules').TestModule; +var requestAnimationFrame = require('requestAnimationFrame'); var React = require('react-native'); var { Text, View, } = React; +var { TestModule } = React.NativeModules; var IntegrationTestHarnessTest = React.createClass({ propTypes: { @@ -39,12 +42,12 @@ var IntegrationTestHarnessTest = React.createClass({ if (this.props.shouldThrow) { throw new Error('Throwing error because shouldThrow'); } - if (!RCTTestModule) { + if (!TestModule) { throw new Error('RCTTestModule is not registered.'); - } else if (!RCTTestModule.markTestCompleted) { + } else if (!TestModule.markTestCompleted) { throw new Error('RCTTestModule.markTestCompleted not defined.'); } - this.setState({done: true}, RCTTestModule.markTestCompleted); + this.setState({done: true}, TestModule.markTestCompleted); }, render() { diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp.js b/IntegrationTests/IntegrationTestsApp.js similarity index 94% rename from Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp.js rename to IntegrationTests/IntegrationTestsApp.js index 5ab306386..95c2697c1 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp.js +++ b/IntegrationTests/IntegrationTestsApp.js @@ -6,14 +6,11 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * - * @providesModule IntegrationTestsApp + * @flow */ 'use strict'; -require('regenerator/runtime'); - var React = require('react-native'); - var { AppRegistry, ScrollView, @@ -23,7 +20,7 @@ var { View, } = React; -/* Keep this list in sync with UIExplorerIntegrationTests.m */ +// Keep this list in sync with UIExplorerIntegrationTests.m var TESTS = [ require('./IntegrationTestHarnessTest'), require('./TimersTest'), diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/js/LayoutEventsTest.js b/IntegrationTests/LayoutEventsTest.js similarity index 98% rename from Examples/UIExplorer/UIExplorerIntegrationTests/js/LayoutEventsTest.js rename to IntegrationTests/LayoutEventsTest.js index 6719585fc..9f7eb7d54 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/js/LayoutEventsTest.js +++ b/IntegrationTests/LayoutEventsTest.js @@ -15,12 +15,11 @@ var React = require('react-native'); var { Image, LayoutAnimation, - NativeModules, StyleSheet, Text, View, } = React; -var TestModule = NativeModules.TestModule; +var { TestModule } = React.NativeModules; var deepDiffer = require('deepDiffer'); diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/js/PromiseTest.js b/IntegrationTests/PromiseTest.js similarity index 80% rename from Examples/UIExplorer/UIExplorerIntegrationTests/js/PromiseTest.js rename to IntegrationTests/PromiseTest.js index c28f4670a..563655c3d 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/js/PromiseTest.js +++ b/IntegrationTests/PromiseTest.js @@ -6,15 +6,14 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * - * @providesModule PromiseTest + * @flow */ 'use strict'; -var RCTTestModule = require('NativeModules').TestModule; var React = require('react-native'); +var { TestModule } = React.NativeModules; var PromiseTest = React.createClass({ - shouldResolve: false, shouldReject: false, shouldSucceedAsync: false, @@ -26,45 +25,45 @@ var PromiseTest = React.createClass({ this.testShouldReject(), this.testShouldSucceedAsync(), this.testShouldThrowAsync(), - ]).then(() => RCTTestModule.markTestPassed( + ]).then(() => TestModule.markTestPassed( this.shouldResolve && this.shouldReject && this.shouldSucceedAsync && this.shouldThrowAsync )); }, testShouldResolve() { - return RCTTestModule + return TestModule .shouldResolve() .then(() => this.shouldResolve = true) .catch(() => this.shouldResolve = false); }, testShouldReject() { - return RCTTestModule + return TestModule .shouldReject() .then(() => this.shouldReject = false) .catch(() => this.shouldReject = true); }, - async testShouldSucceedAsync() { + async testShouldSucceedAsync() : Promise { try { - await RCTTestModule.shouldResolve(); + await TestModule.shouldResolve(); this.shouldSucceedAsync = true; } catch (e) { this.shouldSucceedAsync = false; } }, - async testShouldThrowAsync() { + async testShouldThrowAsync() : Promise { try { - await RCTTestModule.shouldReject(); + await TestModule.shouldReject(); this.shouldThrowAsync = false; } catch (e) { this.shouldThrowAsync = true; } }, - render() { + render() : ReactElement { return ; } diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/js/SimpleSnapshotTest.js b/IntegrationTests/SimpleSnapshotTest.js similarity index 89% rename from Examples/UIExplorer/UIExplorerIntegrationTests/js/SimpleSnapshotTest.js rename to IntegrationTests/SimpleSnapshotTest.js index 20eacec48..2f0e93358 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/js/SimpleSnapshotTest.js +++ b/IntegrationTests/SimpleSnapshotTest.js @@ -5,16 +5,19 @@ * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. + * + * @flow */ 'use strict'; var React = require('react-native'); +var requestAnimationFrame = require('requestAnimationFrame'); + var { StyleSheet, View, } = React; - -var { TestModule } = React.addons; +var { TestModule } = React.NativeModules; var SimpleSnapshotTest = React.createClass({ componentDidMount() { @@ -24,7 +27,7 @@ var SimpleSnapshotTest = React.createClass({ requestAnimationFrame(() => TestModule.verifySnapshot(this.done)); }, - done(success) { + done(success : boolean) { TestModule.markTestPassed(success); }, diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/js/TimersTest.js b/IntegrationTests/TimersTest.js similarity index 95% rename from Examples/UIExplorer/UIExplorerIntegrationTests/js/TimersTest.js rename to IntegrationTests/TimersTest.js index c84dc3192..56fa9235c 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/js/TimersTest.js +++ b/IntegrationTests/TimersTest.js @@ -5,21 +5,27 @@ * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. + * + * @flow */ 'use strict'; -var RCTTestModule = require('NativeModules').TestModule; var React = require('react-native'); +var TimerMixin = require('react-timer-mixin'); + var { StyleSheet, Text, View, } = React; -var TimerMixin = require('react-timer-mixin'); +var { TestModule } = React.NativeModules; var TimersTest = React.createClass({ mixins: [TimerMixin], + _nextTest: () => {}, + _interval: -1, + getInitialState() { return { count: 0, @@ -113,7 +119,7 @@ var TimersTest = React.createClass({ }, done() { - this.setState({done: true}, RCTTestModule.markTestCompleted); + this.setState({done: true}, TestModule.markTestCompleted); }, render() { @@ -140,7 +146,7 @@ var TimersTest = React.createClass({ this.setState({count: this.state.count + 1}); }, - _fail(caller) { + _fail(caller : string) : void { throw new Error('_fail called by ' + caller); }, }); diff --git a/Libraries/RCTTest/RCTTestRunner.h b/Libraries/RCTTest/RCTTestRunner.h index aee9d412b..b5e8430cd 100644 --- a/Libraries/RCTTest/RCTTestRunner.h +++ b/Libraries/RCTTest/RCTTestRunner.h @@ -23,13 +23,19 @@ moduleProvider:(moduleProvider__)] @protocol RCTBridgeModule; +@class RCTBridge; @class RCTRootView; @interface RCTTestRunner : NSObject +/** + * Controls the mode snapshots are run in. If set to true, new snapshots are written to disk, + * otherwise, the UI will be compared to the existing snapshot. + */ @property (nonatomic, assign) BOOL recordMode; -@property (nonatomic, strong) NSURL *scriptURL; + +@property (nonatomic, readonly) NSURL *scriptURL; /** * Initialize a runner. It's recommended that you use the RCTInitRunnerForApp