Move JS integration tests to root folder
Reviewed By: mkonicek Differential Revision: D2658454 fb-gh-sync-id: b639ea995411a7e43903264318b5fca4d2f1e9f7
This commit is contained in:
parent
7a794cc72b
commit
a027218641
Binary file not shown.
Before Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
|
@ -37,10 +37,10 @@
|
||||||
|
|
||||||
NSOperatingSystemVersion version = [NSProcessInfo processInfo].operatingSystemVersion;
|
NSOperatingSystemVersion version = [NSProcessInfo processInfo].operatingSystemVersion;
|
||||||
RCTAssert((version.majorVersion == 8 && version.minorVersion >= 3) || version.majorVersion >= 9, @"Tests should be run on iOS 8.3+, found %zd.%zd.%zd", version.majorVersion, version.minorVersion, version.patchVersion);
|
RCTAssert((version.majorVersion == 8 && version.minorVersion >= 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
|
- (void)testTheTester_waitOneFrame
|
||||||
{
|
{
|
||||||
|
@ -59,16 +59,17 @@ configurationBlock:nil
|
||||||
expectErrorRegex:@"because shouldThrow"];
|
expectErrorRegex:@"because shouldThrow"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - JS tests
|
||||||
|
|
||||||
// This list should be kept in sync with IntegrationTestsApp.js
|
// This list should be kept in sync with IntegrationTestsApp.js
|
||||||
RCT_TEST(IntegrationTestHarnessTest)
|
RCT_TEST(IntegrationTestHarnessTest)
|
||||||
RCT_TEST(TimersTest)
|
RCT_TEST(TimersTest)
|
||||||
RCT_TEST(AsyncStorageTest)
|
RCT_TEST(AsyncStorageTest)
|
||||||
RCT_TEST(AppEventsTest)
|
RCT_TEST(AppEventsTest)
|
||||||
//RCT_TEST(ImageSnapshotTest) // Disabled: #8985988
|
//RCT_TEST(ImageSnapshotTest) // Disabled: #8985988
|
||||||
|
//RCT_TEST(LayoutEventsTest) // Disabled due to flakiness: #8686784
|
||||||
RCT_TEST(SimpleSnapshotTest)
|
RCT_TEST(SimpleSnapshotTest)
|
||||||
|
RCT_TEST(PromiseTest)
|
||||||
|
|
||||||
// Disable due to flakiness: #8686784
|
|
||||||
//RCT_TEST(LayoutEventsTest)
|
|
||||||
//RCT_TEST(PromiseTest)
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -14,12 +14,11 @@
|
||||||
var React = require('react-native');
|
var React = require('react-native');
|
||||||
var {
|
var {
|
||||||
NativeAppEventEmitter,
|
NativeAppEventEmitter,
|
||||||
NativeModules,
|
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
View,
|
View,
|
||||||
} = React;
|
} = React;
|
||||||
var TestModule = NativeModules.TestModule;
|
var { TestModule } = React.NativeModules;
|
||||||
|
|
||||||
var deepDiffer = require('deepDiffer');
|
var deepDiffer = require('deepDiffer');
|
||||||
|
|
|
@ -5,16 +5,18 @@
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* 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
|
* 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.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var RCTTestModule = require('NativeModules').TestModule;
|
|
||||||
var React = require('react-native');
|
var React = require('react-native');
|
||||||
var {
|
var {
|
||||||
AsyncStorage,
|
AsyncStorage,
|
||||||
Text,
|
Text,
|
||||||
View,
|
View,
|
||||||
} = React;
|
} = React;
|
||||||
|
var { TestModule } = React.NativeModules;
|
||||||
|
|
||||||
var deepDiffer = require('deepDiffer');
|
var deepDiffer = require('deepDiffer');
|
||||||
|
|
||||||
|
@ -31,21 +33,21 @@ var VAL_MERGE_EXPECT =
|
||||||
{'foo': 1, 'bar': {'hoo': 2, 'boo': 1}, 'baz': 2, 'moo': {'a': 3}};
|
{'foo': 1, 'bar': {'hoo': 2, 'boo': 1}, 'baz': 2, 'moo': {'a': 3}};
|
||||||
|
|
||||||
// setup in componentDidMount
|
// setup in componentDidMount
|
||||||
var done;
|
var done = (result : ?boolean) => {};
|
||||||
var updateMessage;
|
var updateMessage = (message : string ) => {};
|
||||||
|
|
||||||
function runTestCase(description, fn) {
|
function runTestCase(description : string, fn) {
|
||||||
updateMessage(description);
|
updateMessage(description);
|
||||||
fn();
|
fn();
|
||||||
}
|
}
|
||||||
|
|
||||||
function expectTrue(condition, message) {
|
function expectTrue(condition : boolean, message : string) {
|
||||||
if (!condition) {
|
if (!condition) {
|
||||||
throw new Error(message);
|
throw new Error(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function expectEqual(lhs, rhs, testname) {
|
function expectEqual(lhs, rhs, testname : string) {
|
||||||
expectTrue(
|
expectTrue(
|
||||||
!deepDiffer(lhs, rhs),
|
!deepDiffer(lhs, rhs),
|
||||||
'Error in test ' + testname + ': expected\n' + JSON.stringify(rhs) +
|
'Error in test ' + testname + ': expected\n' + JSON.stringify(rhs) +
|
||||||
|
@ -155,7 +157,7 @@ var AsyncStorageTest = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
done = () => this.setState({done: true}, RCTTestModule.markTestCompleted);
|
done = () => this.setState({done: true}, TestModule.markTestCompleted);
|
||||||
updateMessage = (msg) => {
|
updateMessage = (msg) => {
|
||||||
this.setState({messages: this.state.messages.concat('\n' + msg)});
|
this.setState({messages: this.state.messages.concat('\n' + msg)});
|
||||||
DEBUG && console.log(msg);
|
DEBUG && console.log(msg);
|
|
@ -5,6 +5,8 @@
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* 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
|
* 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.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -13,8 +15,7 @@ var {
|
||||||
Image,
|
Image,
|
||||||
View,
|
View,
|
||||||
} = React;
|
} = React;
|
||||||
|
var { TestModule } = React.NativeModules;
|
||||||
var { TestModule } = React.addons;
|
|
||||||
|
|
||||||
var ImageSnapshotTest = React.createClass({
|
var ImageSnapshotTest = React.createClass({
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -23,7 +24,7 @@ var ImageSnapshotTest = React.createClass({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
done(success) {
|
done(success : boolean) {
|
||||||
TestModule.markTestPassed(success);
|
TestModule.markTestPassed(success);
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,15 +5,18 @@
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* 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
|
* 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.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var RCTTestModule = require('NativeModules').TestModule;
|
var requestAnimationFrame = require('requestAnimationFrame');
|
||||||
var React = require('react-native');
|
var React = require('react-native');
|
||||||
var {
|
var {
|
||||||
Text,
|
Text,
|
||||||
View,
|
View,
|
||||||
} = React;
|
} = React;
|
||||||
|
var { TestModule } = React.NativeModules;
|
||||||
|
|
||||||
var IntegrationTestHarnessTest = React.createClass({
|
var IntegrationTestHarnessTest = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
@ -39,12 +42,12 @@ var IntegrationTestHarnessTest = React.createClass({
|
||||||
if (this.props.shouldThrow) {
|
if (this.props.shouldThrow) {
|
||||||
throw new Error('Throwing error because shouldThrow');
|
throw new Error('Throwing error because shouldThrow');
|
||||||
}
|
}
|
||||||
if (!RCTTestModule) {
|
if (!TestModule) {
|
||||||
throw new Error('RCTTestModule is not registered.');
|
throw new Error('RCTTestModule is not registered.');
|
||||||
} else if (!RCTTestModule.markTestCompleted) {
|
} else if (!TestModule.markTestCompleted) {
|
||||||
throw new Error('RCTTestModule.markTestCompleted not defined.');
|
throw new Error('RCTTestModule.markTestCompleted not defined.');
|
||||||
}
|
}
|
||||||
this.setState({done: true}, RCTTestModule.markTestCompleted);
|
this.setState({done: true}, TestModule.markTestCompleted);
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
|
@ -6,14 +6,11 @@
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* 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.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule IntegrationTestsApp
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
require('regenerator/runtime');
|
|
||||||
|
|
||||||
var React = require('react-native');
|
var React = require('react-native');
|
||||||
|
|
||||||
var {
|
var {
|
||||||
AppRegistry,
|
AppRegistry,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
|
@ -23,7 +20,7 @@ var {
|
||||||
View,
|
View,
|
||||||
} = React;
|
} = React;
|
||||||
|
|
||||||
/* Keep this list in sync with UIExplorerIntegrationTests.m */
|
// Keep this list in sync with UIExplorerIntegrationTests.m
|
||||||
var TESTS = [
|
var TESTS = [
|
||||||
require('./IntegrationTestHarnessTest'),
|
require('./IntegrationTestHarnessTest'),
|
||||||
require('./TimersTest'),
|
require('./TimersTest'),
|
|
@ -15,12 +15,11 @@ var React = require('react-native');
|
||||||
var {
|
var {
|
||||||
Image,
|
Image,
|
||||||
LayoutAnimation,
|
LayoutAnimation,
|
||||||
NativeModules,
|
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
View,
|
View,
|
||||||
} = React;
|
} = React;
|
||||||
var TestModule = NativeModules.TestModule;
|
var { TestModule } = React.NativeModules;
|
||||||
|
|
||||||
var deepDiffer = require('deepDiffer');
|
var deepDiffer = require('deepDiffer');
|
||||||
|
|
|
@ -6,15 +6,14 @@
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* 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.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule PromiseTest
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var RCTTestModule = require('NativeModules').TestModule;
|
|
||||||
var React = require('react-native');
|
var React = require('react-native');
|
||||||
|
var { TestModule } = React.NativeModules;
|
||||||
|
|
||||||
var PromiseTest = React.createClass({
|
var PromiseTest = React.createClass({
|
||||||
|
|
||||||
shouldResolve: false,
|
shouldResolve: false,
|
||||||
shouldReject: false,
|
shouldReject: false,
|
||||||
shouldSucceedAsync: false,
|
shouldSucceedAsync: false,
|
||||||
|
@ -26,45 +25,45 @@ var PromiseTest = React.createClass({
|
||||||
this.testShouldReject(),
|
this.testShouldReject(),
|
||||||
this.testShouldSucceedAsync(),
|
this.testShouldSucceedAsync(),
|
||||||
this.testShouldThrowAsync(),
|
this.testShouldThrowAsync(),
|
||||||
]).then(() => RCTTestModule.markTestPassed(
|
]).then(() => TestModule.markTestPassed(
|
||||||
this.shouldResolve && this.shouldReject &&
|
this.shouldResolve && this.shouldReject &&
|
||||||
this.shouldSucceedAsync && this.shouldThrowAsync
|
this.shouldSucceedAsync && this.shouldThrowAsync
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
|
|
||||||
testShouldResolve() {
|
testShouldResolve() {
|
||||||
return RCTTestModule
|
return TestModule
|
||||||
.shouldResolve()
|
.shouldResolve()
|
||||||
.then(() => this.shouldResolve = true)
|
.then(() => this.shouldResolve = true)
|
||||||
.catch(() => this.shouldResolve = false);
|
.catch(() => this.shouldResolve = false);
|
||||||
},
|
},
|
||||||
|
|
||||||
testShouldReject() {
|
testShouldReject() {
|
||||||
return RCTTestModule
|
return TestModule
|
||||||
.shouldReject()
|
.shouldReject()
|
||||||
.then(() => this.shouldReject = false)
|
.then(() => this.shouldReject = false)
|
||||||
.catch(() => this.shouldReject = true);
|
.catch(() => this.shouldReject = true);
|
||||||
},
|
},
|
||||||
|
|
||||||
async testShouldSucceedAsync() {
|
async testShouldSucceedAsync() : Promise {
|
||||||
try {
|
try {
|
||||||
await RCTTestModule.shouldResolve();
|
await TestModule.shouldResolve();
|
||||||
this.shouldSucceedAsync = true;
|
this.shouldSucceedAsync = true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.shouldSucceedAsync = false;
|
this.shouldSucceedAsync = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async testShouldThrowAsync() {
|
async testShouldThrowAsync() : Promise {
|
||||||
try {
|
try {
|
||||||
await RCTTestModule.shouldReject();
|
await TestModule.shouldReject();
|
||||||
this.shouldThrowAsync = false;
|
this.shouldThrowAsync = false;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.shouldThrowAsync = true;
|
this.shouldThrowAsync = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() : ReactElement {
|
||||||
return <React.View />;
|
return <React.View />;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,16 +5,19 @@
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* 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
|
* 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.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var React = require('react-native');
|
var React = require('react-native');
|
||||||
|
var requestAnimationFrame = require('requestAnimationFrame');
|
||||||
|
|
||||||
var {
|
var {
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
View,
|
View,
|
||||||
} = React;
|
} = React;
|
||||||
|
var { TestModule } = React.NativeModules;
|
||||||
var { TestModule } = React.addons;
|
|
||||||
|
|
||||||
var SimpleSnapshotTest = React.createClass({
|
var SimpleSnapshotTest = React.createClass({
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -24,7 +27,7 @@ var SimpleSnapshotTest = React.createClass({
|
||||||
requestAnimationFrame(() => TestModule.verifySnapshot(this.done));
|
requestAnimationFrame(() => TestModule.verifySnapshot(this.done));
|
||||||
},
|
},
|
||||||
|
|
||||||
done(success) {
|
done(success : boolean) {
|
||||||
TestModule.markTestPassed(success);
|
TestModule.markTestPassed(success);
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,21 +5,27 @@
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* 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
|
* 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.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var RCTTestModule = require('NativeModules').TestModule;
|
|
||||||
var React = require('react-native');
|
var React = require('react-native');
|
||||||
|
var TimerMixin = require('react-timer-mixin');
|
||||||
|
|
||||||
var {
|
var {
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
View,
|
View,
|
||||||
} = React;
|
} = React;
|
||||||
var TimerMixin = require('react-timer-mixin');
|
var { TestModule } = React.NativeModules;
|
||||||
|
|
||||||
var TimersTest = React.createClass({
|
var TimersTest = React.createClass({
|
||||||
mixins: [TimerMixin],
|
mixins: [TimerMixin],
|
||||||
|
|
||||||
|
_nextTest: () => {},
|
||||||
|
_interval: -1,
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return {
|
return {
|
||||||
count: 0,
|
count: 0,
|
||||||
|
@ -113,7 +119,7 @@ var TimersTest = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
done() {
|
done() {
|
||||||
this.setState({done: true}, RCTTestModule.markTestCompleted);
|
this.setState({done: true}, TestModule.markTestCompleted);
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -140,7 +146,7 @@ var TimersTest = React.createClass({
|
||||||
this.setState({count: this.state.count + 1});
|
this.setState({count: this.state.count + 1});
|
||||||
},
|
},
|
||||||
|
|
||||||
_fail(caller) {
|
_fail(caller : string) : void {
|
||||||
throw new Error('_fail called by ' + caller);
|
throw new Error('_fail called by ' + caller);
|
||||||
},
|
},
|
||||||
});
|
});
|
|
@ -23,13 +23,19 @@
|
||||||
moduleProvider:(moduleProvider__)]
|
moduleProvider:(moduleProvider__)]
|
||||||
|
|
||||||
@protocol RCTBridgeModule;
|
@protocol RCTBridgeModule;
|
||||||
|
@class RCTBridge;
|
||||||
|
|
||||||
@class RCTRootView;
|
@class RCTRootView;
|
||||||
|
|
||||||
@interface RCTTestRunner : NSObject
|
@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, assign) BOOL recordMode;
|
||||||
@property (nonatomic, strong) NSURL *scriptURL;
|
|
||||||
|
@property (nonatomic, readonly) NSURL *scriptURL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize a runner. It's recommended that you use the RCTInitRunnerForApp
|
* Initialize a runner. It's recommended that you use the RCTInitRunnerForApp
|
||||||
|
|
Loading…
Reference in New Issue