mirror of
https://github.com/status-im/react-native.git
synced 2025-01-12 10:34:57 +00:00
Initial Detox E2E iOS configuration to be run on RNTester (#20235)
Summary: This PR adds initial setup for Detox E2E iOS and some tests for ButtonExample. Pull Request resolved: https://github.com/facebook/react-native/pull/20235 Reviewed By: hramos Differential Revision: D8924525 Pulled By: TheSavior fbshipit-source-id: 8117fc1559c2e9cb831f7b081aa8f4ddc8ba7401
This commit is contained in:
parent
2ca7701aae
commit
7f0a4f72b4
@ -324,16 +324,12 @@ aliases:
|
||||
- &run-objc-ios-e2e-tests
|
||||
name: iOS End-to-End Test Suite
|
||||
command: |
|
||||
if [ $((0 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then
|
||||
node ./scripts/run-ci-e2e-tests.js --ios --retries 3;
|
||||
fi
|
||||
node ./scripts/run-ci-e2e-tests.js --ios --retries 3;
|
||||
|
||||
- &run-objc-tvos-e2e-tests
|
||||
name: tvOS End-to-End Test Suite
|
||||
command: |
|
||||
if [ $((1 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then
|
||||
node ./scripts/run-ci-e2e-tests.js --tvos --js --retries 3;
|
||||
fi
|
||||
node ./scripts/run-ci-e2e-tests.js --tvos --js --retries 3;
|
||||
|
||||
- &run-android-e2e-tests
|
||||
name: Android End-to-End Test Suite
|
||||
@ -443,13 +439,13 @@ jobs:
|
||||
# Runs end to end tests
|
||||
test_end_to_end:
|
||||
<<: *macos_defaults
|
||||
parallelism: 2
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: ~/react-native
|
||||
|
||||
- run: *boot-simulator-iphone
|
||||
- run: *boot-simulator-appletv
|
||||
- run:
|
||||
name: Boot iOS Simulator
|
||||
command: xcrun simctl boot "iPhone 5s" || true
|
||||
|
||||
- run:
|
||||
name: Configure Environment Variables
|
||||
@ -465,8 +461,20 @@ jobs:
|
||||
node -v
|
||||
|
||||
- run: *run-objc-ios-e2e-tests
|
||||
# Disabled for now
|
||||
# - run: *run-objc-tvos-e2e-tests
|
||||
|
||||
- run:
|
||||
name: Install Apple Simulator Utilities
|
||||
command: |
|
||||
brew tap wix/brew
|
||||
brew install applesimutils
|
||||
|
||||
- run:
|
||||
name: Build iOS App for Simulator
|
||||
command: yarn run build-ios-e2e
|
||||
|
||||
- run:
|
||||
name: Run Detox Tests
|
||||
command: yarn run test-ios-e2e
|
||||
|
||||
- store_test_results:
|
||||
path: ~/react-native/reports/junit
|
||||
|
@ -52,7 +52,8 @@
|
||||
"setTimeout": false,
|
||||
"window": false,
|
||||
"XMLHttpRequest": false,
|
||||
"pit": false
|
||||
"pit": false,
|
||||
"jasmine": true
|
||||
},
|
||||
|
||||
"rules": {
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -72,3 +72,4 @@ package-lock.json
|
||||
|
||||
# ReactCommon subdir shouldn't have Xcode project
|
||||
/ReactCommon/**/*.xcodeproj
|
||||
RNTester/build
|
||||
|
6
RNTester/e2e/config.json
Normal file
6
RNTester/e2e/config.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"setupTestFrameworkScriptFile" : "./init.js",
|
||||
"testEnvironment": "node",
|
||||
"bail": true,
|
||||
"verbose": true
|
||||
}
|
30
RNTester/e2e/init.js
Normal file
30
RNTester/e2e/init.js
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const detox = require('detox');
|
||||
const config = require('../../package.json').detox;
|
||||
const adapter = require('detox/runners/jest/adapter');
|
||||
|
||||
jest.setTimeout(480000);
|
||||
jasmine.getEnv().addReporter(adapter);
|
||||
|
||||
beforeAll(async () => {
|
||||
await detox.init(config);
|
||||
});
|
||||
|
||||
beforeEach(async function() {
|
||||
await adapter.beforeEach();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await adapter.afterAll();
|
||||
await detox.cleanup();
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', (reason, p) => {
|
||||
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
|
||||
});
|
47
RNTester/e2e/sanity.test.js
Normal file
47
RNTester/e2e/sanity.test.js
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/* global device, element, by, expect */
|
||||
|
||||
describe('Sanity', () => {
|
||||
beforeEach(async () => {
|
||||
await device.reloadReactNative();
|
||||
await element(by.label(`<Button> Simple React Native button component.`)).tap();
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
//TODO - remove app state persistency, till then, we must go back to main screen,
|
||||
await element(by.label('Back')).tap();
|
||||
});
|
||||
|
||||
it('Simple button should be tappable', async () => {
|
||||
await element(by.label('Press Me')).tap();
|
||||
await expect(element(by.text('Simple has been pressed!'))).toBeVisible();
|
||||
await element(by.text('OK')).tap();
|
||||
});
|
||||
|
||||
it('Adjusted color button should be tappable', async () => {
|
||||
await element(by.label('Press Purple')).tap();
|
||||
await expect(element(by.text('Purple has been pressed!'))).toBeVisible();
|
||||
await element(by.text('OK')).tap();
|
||||
});
|
||||
|
||||
it(`Two buttons with JustifyContent:'space-between' should be tappable`, async () => {
|
||||
await element(by.label('This looks great!')).tap();
|
||||
await expect(element(by.text('Left has been pressed!'))).toBeVisible();
|
||||
await element(by.text('OK')).tap();
|
||||
|
||||
await element(by.label('Ok!')).tap();
|
||||
await expect(element(by.text('Right has been pressed!'))).toBeVisible();
|
||||
await element(by.text('OK')).tap();
|
||||
});
|
||||
|
||||
it('Disabled button should not interact', async () => {
|
||||
await element(by.label('I Am Disabled')).tap();
|
||||
await expect(element(by.text('Disabled has been pressed!'))).toBeNotVisible();
|
||||
});
|
||||
});
|
@ -14,9 +14,9 @@ const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {Alert, Button, View} = ReactNative;
|
||||
|
||||
const onButtonPress = () => {
|
||||
Alert.alert('Button has been pressed!');
|
||||
};
|
||||
function onButtonPress(buttonName) {
|
||||
Alert.alert(`${buttonName} has been pressed!`);
|
||||
}
|
||||
|
||||
exports.displayName = 'ButtonExample';
|
||||
exports.framework = 'React';
|
||||
@ -33,7 +33,7 @@ exports.examples = [
|
||||
render: function() {
|
||||
return (
|
||||
<Button
|
||||
onPress={onButtonPress}
|
||||
onPress={() => onButtonPress('Simple')}
|
||||
title="Press Me"
|
||||
accessibilityLabel="See an informative alert"
|
||||
/>
|
||||
@ -49,7 +49,7 @@ exports.examples = [
|
||||
render: function() {
|
||||
return (
|
||||
<Button
|
||||
onPress={onButtonPress}
|
||||
onPress={() => onButtonPress('Purple')}
|
||||
title="Press Purple"
|
||||
color="#841584"
|
||||
accessibilityLabel="Learn more about purple"
|
||||
@ -65,12 +65,12 @@ exports.examples = [
|
||||
return (
|
||||
<View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
|
||||
<Button
|
||||
onPress={onButtonPress}
|
||||
onPress={() => onButtonPress('Left')}
|
||||
title="This looks great!"
|
||||
accessibilityLabel="This sounds great!"
|
||||
/>
|
||||
<Button
|
||||
onPress={onButtonPress}
|
||||
onPress={() => onButtonPress('Right')}
|
||||
title="Ok!"
|
||||
color="#841584"
|
||||
accessibilityLabel="Ok, Great!"
|
||||
@ -86,7 +86,7 @@ exports.examples = [
|
||||
return (
|
||||
<Button
|
||||
disabled
|
||||
onPress={onButtonPress}
|
||||
onPress={() => onButtonPress('Disabled')}
|
||||
title="I Am Disabled"
|
||||
accessibilityLabel="See an informative alert"
|
||||
/>
|
||||
|
21
package.json
21
package.json
@ -33,7 +33,8 @@
|
||||
"testPathIgnorePatterns": [
|
||||
"Libraries/Renderer",
|
||||
"/node_modules/",
|
||||
"local-cli/templates/"
|
||||
"local-cli/templates/",
|
||||
"RNTester/e2e"
|
||||
],
|
||||
"haste": {
|
||||
"defaultPlatform": "ios",
|
||||
@ -137,7 +138,9 @@
|
||||
"test-android-all": "yarn run docker-build-android && yarn run test-android-run-unit && yarn run test-android-run-instrumentation && yarn run test-android-run-e2e",
|
||||
"test-android-instrumentation": "yarn run docker-build-android && yarn run test-android-run-instrumentation",
|
||||
"test-android-unit": "yarn run docker-build-android && yarn run test-android-run-unit",
|
||||
"test-android-e2e": "yarn run docker-build-android && yarn run test-android-run-e2e"
|
||||
"test-android-e2e": "yarn run docker-build-android && yarn run test-android-run-e2e",
|
||||
"build-ios-e2e": "detox build -c ios.sim.release",
|
||||
"test-ios-e2e": "detox test -c ios.sim.release --cleanup"
|
||||
},
|
||||
"bin": {
|
||||
"react-native": "local-cli/wrong-react-native.js"
|
||||
@ -203,6 +206,7 @@
|
||||
"async": "^2.4.0",
|
||||
"babel-eslint": "9.0.0-beta.2",
|
||||
"babel-generator": "^6.26.0",
|
||||
"detox": "^8.0.0",
|
||||
"eslint": "5.1.0",
|
||||
"eslint-config-fb-strict": "22.1.0",
|
||||
"eslint-config-fbjs": "2.0.1",
|
||||
@ -220,5 +224,18 @@
|
||||
"react-test-renderer": "16.4.1",
|
||||
"shelljs": "^0.7.8",
|
||||
"sinon": "^2.2.0"
|
||||
},
|
||||
"detox": {
|
||||
"test-runner": "jest",
|
||||
"runner-config": "RNTester/e2e/config.json",
|
||||
"specs": "RNTester/e2e",
|
||||
"configurations": {
|
||||
"ios.sim.release": {
|
||||
"binaryPath": "RNTester/build/Build/Products/Release-iphonesimulator/RNTester.app/",
|
||||
"build": "xcodebuild -project RNTester/RNTester.xcodeproj -scheme RNTester -configuration Release -sdk iphonesimulator -derivedDataPath RNTester/build -quiet",
|
||||
"type": "ios.simulator",
|
||||
"name": "iPhone 8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user