Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added initial implementation of detoxjs for e2e testing #19

Merged
merged 1 commit into from
Jun 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ android {
}

dependencies {
compile project(':react-native-camera-kit')
compile project(':react-native-navigation')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import com.reactnativenavigation.NavigationApplication;
import com.wix.RNCameraKit.RNCameraKitPackage;

import java.util.Arrays;
import java.util.List;
Expand All @@ -24,7 +25,8 @@ public boolean isDebug() {
public List<ReactPackage> createAdditionalReactPackages() {
return Arrays.<ReactPackage>asList(
new VectorIconsPackage(),
new ReactNativePushNotificationPackage()
new ReactNativePushNotificationPackage(),
new RNCameraKitPackage()
);
}

Expand Down
2 changes: 2 additions & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
rootProject.name = 'ReactNativeStarter'
include ':react-native-camera-kit'
project(':react-native-camera-kit').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera-kit/android')
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/android/app')
include ':react-native-vector-icons'
Expand Down
29 changes: 18 additions & 11 deletions e2e/config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
export const serverConfig = process.env.NODE_ENV === 'e2eSauce' ? {
host: 'ondemand.saucelabs.com',
port: 80,
auth: `${process.env.SAUCE_USERNAME}:${process.env.SAUCE_ACCESS_KEY}`,
} : {
host: 'localhost',
port: 4723,
};
export const IOS_SIM = '1991C14B-9892-44E8-BCEF-EA63F308972E';

export const app = process.env.NODE_ENV === 'e2eSauce' ?
'sauce-storage:ReactNativeMobilePOC.zip' :
'ios/build/Build/Products/Debug-iphonesimulator/ReactNativeMobilePOC.app';
export default {
specs: 'e2e',
configurations: {
'ios.sim.release': {
binaryPath: 'ios/build/Build/Products/Release-iphonesimulator/ReactNativeStarter.app',
build: 'export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -project ios/ReactNativeStarter.xcodeproj -scheme ReactNativeStarter -configuration Release -sdk iphonesimulator -derivedDataPath ios/build',
type: 'ios.simulator',
name: IOS_SIM,
},
'ios.sim.debug': {
binaryPath: 'ios/build/Build/Products/Debug-iphonesimulator/ReactNativeStarter.app',
build: 'xcodebuild -project ios/ReactNativeStarter.xcodeproj -scheme ReactNativeStarter -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build',
type: 'ios.simulator',
name: IOS_SIM,
},
},
};
9 changes: 0 additions & 9 deletions e2e/e2e-setup.js

This file was deleted.

32 changes: 32 additions & 0 deletions e2e/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*eslint-disable */

// add extra commands after jest validation executed
process.argv = [...process.argv, '--configuration', 'ios.sim.release'];

import config, { IOS_SIM } from './config';
import cp from 'child_process';

const detox = require('detox');

async function setPermissions(permissions) {
await cp.execSync(
`applesimutils \\
--simulator "${IOS_SIM}" \\
--bundle io.rangle.starter.app \\
--setPermissions "${permissions.join()}"`,
{
stdio: 'inherit',
},
);
}


beforeAll(async () => {
await detox.init(config);
await setPermissions(['camera=YES']);
await device.relaunchApp();
}, 25000);

afterAll(async () => {
await detox.cleanup();
});
37 changes: 37 additions & 0 deletions ios/ReactNativeStarter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
1781BC2E46F546AABF72766B /* MaterialCommunityIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6AA7C142FA1A4D1CA35E7E2D /* MaterialCommunityIcons.ttf */; };
1FBE2A525D2A4FAE8685663E /* Entypo.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 5C65D695ED174D5990A410B8 /* Entypo.ttf */; };
253DECFAA63E491D82C71620 /* libReactNativeCameraKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D1AE908607B4D8AB9E28709 /* libReactNativeCameraKit.a */; };
33EA60CA68FF4B4395CFF28D /* EvilIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 22286EF161D6407CB8C084F4 /* EvilIcons.ttf */; };
38733021E63C49458C94906C /* MaterialIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = BDD609F5DF18451881B79761 /* MaterialIcons.ttf */; };
5A31C09AE78A4B9C9E8CECA1 /* libReactNativeNavigation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BFDA3C33D52B42929A4459F5 /* libReactNativeNavigation.a */; };
Expand Down Expand Up @@ -109,6 +110,13 @@
remoteGlobalIDString = D8AFADBD1BEE6F3F00A4592D;
remoteInfo = ReactNativeNavigation;
};
05A56FCE1EC64F8D005FD9FB /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 4EB19F1669DC479DA5EADAC9 /* ReactNativeCameraKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 2646934E1CFB2A6B00F3A740;
remoteInfo = ReactNativeCameraKit;
};
139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */;
Expand Down Expand Up @@ -275,10 +283,12 @@
146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = "<group>"; };
22286EF161D6407CB8C084F4 /* EvilIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = EvilIcons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/EvilIcons.ttf"; sourceTree = "<group>"; };
4A13DDA7347045929E3C5640 /* Ionicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Ionicons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Ionicons.ttf"; sourceTree = "<group>"; };
4EB19F1669DC479DA5EADAC9 /* ReactNativeCameraKit.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = ReactNativeCameraKit.xcodeproj; path = "../node_modules/react-native-camera-kit/ios/lib/ReactNativeCameraKit.xcodeproj"; sourceTree = "<group>"; };
5C65D695ED174D5990A410B8 /* Entypo.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Entypo.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Entypo.ttf"; sourceTree = "<group>"; };
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = "<group>"; };
65C5D87DBB614BA4B05F697A /* RNVectorIcons.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNVectorIcons.xcodeproj; path = "../node_modules/react-native-vector-icons/RNVectorIcons.xcodeproj"; sourceTree = "<group>"; };
6AA7C142FA1A4D1CA35E7E2D /* MaterialCommunityIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = MaterialCommunityIcons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/MaterialCommunityIcons.ttf"; sourceTree = "<group>"; };
6D1AE908607B4D8AB9E28709 /* libReactNativeCameraKit.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libReactNativeCameraKit.a; sourceTree = "<group>"; };
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
84CA9E9EFFCD40E785A1F16A /* libRNVectorIcons.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNVectorIcons.a; sourceTree = "<group>"; };
Expand Down Expand Up @@ -318,6 +328,7 @@
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
F39DC8F5FDC045B38870089D /* libRNVectorIcons.a in Frameworks */,
5A31C09AE78A4B9C9E8CECA1 /* libReactNativeNavigation.a in Frameworks */,
253DECFAA63E491D82C71620 /* libReactNativeCameraKit.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -408,6 +419,14 @@
name = Products;
sourceTree = "<group>";
};
05A56FB01EC64F8B005FD9FB /* Products */ = {
isa = PBXGroup;
children = (
05A56FCF1EC64F8D005FD9FB /* libReactNativeCameraKit.a */,
);
name = Products;
sourceTree = "<group>";
};
139105B71AF99BAD00B5F7CC /* Products */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -490,6 +509,7 @@
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
65C5D87DBB614BA4B05F697A /* RNVectorIcons.xcodeproj */,
960F39EDFEED46CC9B2C6181 /* ReactNativeNavigation.xcodeproj */,
4EB19F1669DC479DA5EADAC9 /* ReactNativeCameraKit.xcodeproj */,
);
name = Libraries;
sourceTree = "<group>";
Expand Down Expand Up @@ -664,6 +684,10 @@
ProductGroup = 146834001AC3E56700842450 /* Products */;
ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */;
},
{
ProductGroup = 05A56FB01EC64F8B005FD9FB /* Products */;
ProjectRef = 4EB19F1669DC479DA5EADAC9 /* ReactNativeCameraKit.xcodeproj */;
},
{
ProductGroup = 05A262B31EC2391C0084F897 /* Products */;
ProjectRef = 960F39EDFEED46CC9B2C6181 /* ReactNativeNavigation.xcodeproj */;
Expand Down Expand Up @@ -745,6 +769,13 @@
remoteRef = 05A262D11EC2391C0084F897 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
05A56FCF1EC64F8D005FD9FB /* libReactNativeCameraKit.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libReactNativeCameraKit.a;
remoteRef = 05A56FCE1EC64F8D005FD9FB /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
139105C11AF99BAD00B5F7CC /* libRCTSettings.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
Expand Down Expand Up @@ -973,13 +1004,15 @@
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-navigation/ios/**",
"$(SRCROOT)/../node_modules/react-native-camera-kit/ios/lib/ReactNativeCameraKit",
);
INFOPLIST_FILE = ReactNativeStarterTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
Expand All @@ -1000,13 +1033,15 @@
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-navigation/ios/**",
"$(SRCROOT)/../node_modules/react-native-camera-kit/ios/lib/ReactNativeCameraKit",
);
INFOPLIST_FILE = ReactNativeStarterTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
Expand All @@ -1033,6 +1068,7 @@
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native/Libraries/PushNotificationIOS",
"$(SRCROOT)/../node_modules/react-native-navigation/ios/**",
"$(SRCROOT)/../node_modules/react-native-camera-kit/ios/lib/ReactNativeCameraKit",
);
INFOPLIST_FILE = ReactNativeStarter/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down Expand Up @@ -1061,6 +1097,7 @@
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native/Libraries/PushNotificationIOS",
"$(SRCROOT)/../node_modules/react-native-navigation/ios/**",
"$(SRCROOT)/../node_modules/react-native-camera-kit/ios/lib/ReactNativeCameraKit",
);
INFOPLIST_FILE = ReactNativeStarter/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down
6 changes: 6 additions & 0 deletions ios/ReactNativeStarter/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSMicrophoneUsageDescription</key>
<string>Use microphone</string>
<key>NSCameraUsageDescription</key>
<string>Use pictures</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Use pictures</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
Expand Down
5 changes: 3 additions & 2 deletions jest-e2e.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"preset": "react-native",
"testPathIgnorePatterns": ["/node_modules/", "src"],
"testPathIgnorePatterns": ["/node_modules/"],
"verbose": true,
"bail": false,
"testMatch": ["**/?(*.)(e2e).js"],
"setupTestFrameworkScriptFile": "./e2e/e2e-setup.js"
"setupTestFrameworkScriptFile": "./e2e/init.js"
}
26 changes: 25 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,20 @@
"clean:watchman": "watchman watch-del-all",
"tcp-reverse": "adb reverse tcp:8081 tcp:8081",
"flow": "node_modules/.bin/flow",
"flow-stop": "node_modules/.bin/flow stop"
"flow-stop": "node_modules/.bin/flow stop",
"e2e": "jest -c jest-e2e.config.json"
},
"dependencies": {
"ramda": "^0.23.0",
"react": "16.0.0-alpha.6",
"react-native": "0.44.0",
"react-native-camera-kit": "^5.2.13",
"react-native-navigation": "v2.0.0",
"react-native-push-notification": "^2.2.1",
"react-native-style-tachyons": "^3.3.0",
"react-native-vector-icons": "^4.0.1",
"react-redux": "^5.0.3",
"recompose": "^0.23.4",
"redux": "^3.6.0",
"redux-logger": "^2.8.2",
"redux-persist": "^4.5.0",
Expand All @@ -43,13 +46,16 @@
},
"devDependencies": {
"appium": "^1.6.3",
"babel-cli": "^6.24.1",
"babel-eslint": "^7.1.1",
"babel-jest": "19.0.0",
"babel-plugin-module-resolver": "^2.7.0",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.24.0",
"babel-preset-react-native": "1.9.1",
"chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"detox": "^5.0.12",
"eslint": "^3.17.1",
"eslint-config-airbnb": "^14.1.0",
"eslint-plugin-flowtype": "^2.32.1",
Expand All @@ -59,9 +65,27 @@
"eslint-plugin-react": "^6.10.0",
"flow-bin": "^0.45.0",
"jest": "19.0.2",
"mocha": "^3.4.2",
"react-devtools": "^2.0.12",
"react-test-renderer": "16.0.0-alpha.6"
},
"detox": {
"specs": "e2e",
"configurations": {
"ios.sim.release": {
"binaryPath": "ios/build/Build/Products/Release-iphonesimulator/ReactNativeStarter.app",
"build": "export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -project ios/ReactNativeStarter.xcodeproj -scheme ReactNativeStarter -configuration Release -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"name": "iPhone 7 Plus"
},
"ios.sim.debug": {
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/ReactNativeStarter.app",
"build": "xcodebuild -project ios/ReactNativeStarter.xcodeproj -scheme ReactNativeStarter -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"name": "iPhone 7 Plus"
}
}
},
"jest": {
"preset": "react-native"
},
Expand Down
10 changes: 10 additions & 0 deletions src/components/home.e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// @flow
describe('Home suite', () => {
beforeEach(async () => {
await device.reloadReactNative();
});

it('should have a home view', async () => {
await expect(element(by.id('home'))).toBeVisible();
});
});
8 changes: 4 additions & 4 deletions src/components/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import type { Element } from 'react';
import React from 'react';
import { View, Text } from 'react-native';
import { s } from 'src/styles';
import { Page } from './page';

export const Home = (props: HomeProps): Element<any> => (
<Page>
<View style={[s.flx_i, s.jcc]}>
<View
testID='home'
style={[s.flx_i, s.jcc]}
>
<Text>Welcome to home</Text>
</View>
</Page>
);

declare type HomeProps = {
Expand Down
1 change: 0 additions & 1 deletion src/components/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './home';
export * from './search';
export * from './page';
Loading