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

E2E tests setup #2383

Merged
merged 3 commits into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fixed android e2e tests
  • Loading branch information
jmysliv committed Sep 8, 2021
commit 4ed4b25dc4c897f7f88627ef506150068e57acaa
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,7 @@ android/keystores/debug.keystore
ios/Pods/
# generated by bob
lib/
react-native-reanimated-tests.js
react-native-reanimated-tests.js

# eclipse
*.settings**
7 changes: 4 additions & 3 deletions Example/.detoxrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
"ios": {
"type": "ios.app",
"binaryPath": "./ios/build/Build/Products/Debug-iphonesimulator/ReanimatedExample.app",
"build": "export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -project ios/example.xcodeproj -UseNewBuildSystem=NO -scheme example -configuration Release -sdk iphonesimulator -derivedDataPath ios/build -quiet"
"build": "export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -project ios/ReanimatedExample.xcodeproj -UseNewBuildSystem=NO -scheme ReanimatedExample -configuration Release -sdk iphonesimulator -derivedDataPath ios/build -quiet"
},
"android": {
"type": "android.apk",
"binaryPath": "./android/app/build/outputs/apk/release/app-release.apk",
"build": "cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd .."
"testBinaryPath": "./android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk",
"binaryPath": "./android/app/build/outputs/apk/debug/app-debug.apk",
"build": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && cd android && ./gradlew :app:assembleDebug :app:assembleAndroidTest && cd .."
}
},
"devices": {
Expand Down
2 changes: 0 additions & 2 deletions Example/android/.settings/org.eclipse.buildship.core.prefs

This file was deleted.

6 changes: 0 additions & 6 deletions Example/android/app/.classpath

This file was deleted.

4 changes: 3 additions & 1 deletion Example/android/app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.keystore
*pass
*pass
*drawable-**
*assets
8 changes: 8 additions & 0 deletions Example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ android {
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
splits {
abi {
Expand Down Expand Up @@ -154,6 +156,10 @@ android {
pickFirst 'lib/**/libfolly_json.so'
pickFirst 'lib/**/jscexecutor.so'
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}

dependencies {
Expand All @@ -168,6 +174,8 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules

androidTestImplementation('com.wix:detox:+')

implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group: 'com.facebook.fbjni'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.swmansion.reanimated.example;

import com.wix.detox.Detox;
import com.wix.detox.config.DetoxConfig;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class DetoxTest {
// Replace 'MainActivity' with the value of android:name entry in
// <activity> in AndroidManifest.xml
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);

@Test
public void runDetoxTests() {
// This is optional - in case you've decided to integrate TestButler
// See https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#8-test-butler-support-optional
// TestButlerProbe.assertReadyIfInstalled();

DetoxConfig detoxConfig = new DetoxConfig();
detoxConfig.idlePolicyConfig.masterTimeoutSec = 90;
detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60;
detoxConfig.rnContextLoadTimeoutSec = (com.swmansion.reanimated.example.BuildConfig.DEBUG ? 180 : 60);

Detox.runTests(mActivityRule, detoxConfig);
}
}
3 changes: 2 additions & 1 deletion Example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security_config">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">10.0.2.2</domain>
<domain includeSubdomains="true">localhost</domain>
</domain-config>
</network-security-config>
3 changes: 2 additions & 1 deletion Example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ buildscript {

dependencies {
classpath('com.android.tools.build:gradle:4.2.1')
classpath 'de.undercouch:gradle-download-task:4.0.0'
classpath 'de.undercouch:gradle-download-task:4.1.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -32,6 +32,7 @@ allprojects {
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
url "$rootDir/../node_modules/detox/Detox-android"
}
maven { url 'https://www.jitpack.io' }
google()
Expand Down
1 change: 1 addition & 0 deletions Example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ android.useAndroidX=true
android.enableJetifier=true
# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.93.0
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
2 changes: 1 addition & 1 deletion Example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
4 changes: 2 additions & 2 deletions Example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"web": "expo start --web || expo start --web --web-only",
"lint-check": "eslint --ext '.js,.ts,.tsx' src/ && yarn prettier --check src/",
"ts-check": "yarn tsc",
"e2e:android": "yarn detox build --configuration android && yarn detox test --configuration android",
"e2e:test": "yarn detox build --configuration ios && yarn detox test --configuration ios"
"e2e:android": "node ./scripts/generateIndex.js --test && yarn detox build --configuration android && yarn detox test --configuration android",
"e2e:ios": "node ./scripts/generateIndex.js --test && yarn detox build --configuration ios && yarn detox test --configuration ios"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.28",
Expand Down
6 changes: 0 additions & 6 deletions android/.classpath

This file was deleted.

13 changes: 0 additions & 13 deletions android/.settings/org.eclipse.buildship.core.prefs

This file was deleted.

2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ buildscript {
}
dependencies {
classpath('com.android.tools.build:gradle:4.2.1')
classpath("de.undercouch:gradle-download-task:4.0.4")
classpath("de.undercouch:gradle-download-task:4.1.2")
}
}

Expand Down