-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ffc1a23
commit 5245041
Showing
14 changed files
with
864 additions
and
31 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Detox Android | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
runs-on: macos-latest | ||
timeout-minutes: 15 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14' | ||
|
||
- uses: c-hive/gha-yarn-cache@v1 | ||
- name: Yarn | ||
run: | | ||
cd ExampleProject | ||
yarn install --frozen-lockfile | ||
- name: Use specific Java version for sdkmanager to work | ||
uses: joschi/setup-jdk@v2 | ||
with: | ||
java-version: '8' | ||
architecture: 'x64' | ||
|
||
- name: Cache Gradle Wrapper | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} | ||
|
||
- name: Cache Gradle Dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.gradle/caches | ||
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle-caches- | ||
- name: Download Android Emulator Image | ||
run: | | ||
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install "system-images;android-29;google_apis;x86" | ||
echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd --force --name Pixel_3a_API_30_x86 --device "Nexus 5X" -k 'system-images;android-29;google_apis;x86' | ||
$ANDROID_HOME/emulator/emulator -list-avds | ||
- name: Android Emulator | ||
timeout-minutes: 10 | ||
continue-on-error: true | ||
run: | | ||
echo "Starting emulator" | ||
nohup $ANDROID_HOME/emulator/emulator -avd Pixel_3a_API_30_x86 -no-audio -no-snapshot -no-window & | ||
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82' | ||
$ANDROID_HOME/platform-tools/adb devices | ||
echo "Emulator started" | ||
- name: Build for detox | ||
run: | | ||
cd ExampleProject | ||
yarn run 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/ | ||
yarn run build-detox-android | ||
- name: Android Detox | ||
run: | | ||
cd ExampleProject | ||
yarn run test-detox-android |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,3 +54,4 @@ buck-out/ | |
|
||
# Bundle artifact | ||
*.jsbundle | ||
ExampleProject/android/app/src/main/assets/index.android.bundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"testRunner": "jest", | ||
"runnerConfig": "e2e/config.json", | ||
"apps": { | ||
"ios": { | ||
"type": "ios.app", | ||
"binaryPath": "SPECIFY_PATH_TO_YOUR_APP_BINARY" | ||
}, | ||
"android.debug": { | ||
"type": "android.apk", | ||
"binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk", | ||
"build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug --no-daemon && cd .." | ||
}, | ||
"android.release": { | ||
"type": "android.apk", | ||
"binaryPath": "android/app/build/outputs/apk/release/app-release.apk", | ||
"build": "cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release --no-daemon && cd .." | ||
} | ||
}, | ||
"devices": { | ||
"simulator": { | ||
"type": "ios.simulator", | ||
"device": { | ||
"type": "iPhone 11" | ||
} | ||
}, | ||
"emulator": { | ||
"type": "android.emulator", | ||
"device": { | ||
"avdName": "Pixel_3a_API_30_x86" | ||
} | ||
} | ||
}, | ||
"configurations": { | ||
"ios": { | ||
"device": "simulator", | ||
"app": "ios" | ||
}, | ||
"android.debug": { | ||
"device": "emulator", | ||
"app": "android.debug" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
ExampleProject/android/app/src/androidTest/java/com/example/DetoxTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Replace "com.example" here and below with your app's package name from the top of MainActivity.java | ||
package com.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 { | ||
@Rule | ||
// Replace 'MainActivity' with the value of android:name entry in | ||
// <activity> in AndroidManifest.xml | ||
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false); | ||
|
||
@Test | ||
public void runDetoxTests() { | ||
DetoxConfig detoxConfig = new DetoxConfig(); | ||
detoxConfig.idlePolicyConfig.masterTimeoutSec = 90; | ||
detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60; | ||
detoxConfig.rnContextLoadTimeoutSec = (com.example.BuildConfig.DEBUG ? 180 : 60); | ||
|
||
Detox.runTests(mActivityRule, detoxConfig); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "Example", | ||
"displayName": "Example" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"testEnvironment": "./environment", | ||
"testRunner": "jest-circus/runner", | ||
"testTimeout": 120000, | ||
"testRegex": "\\.e2e\\.js$", | ||
"reporters": ["detox/runners/jest/streamlineReporter"], | ||
"verbose": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { | ||
DetoxCircusEnvironment, | ||
SpecReporter, | ||
WorkerAssignReporter, | ||
} = require('detox/runners/jest-circus'); | ||
|
||
class CustomDetoxEnvironment extends DetoxCircusEnvironment { | ||
constructor(config, context) { | ||
super(config, context); | ||
|
||
// Can be safely removed, if you are content with the default value (=300000ms) | ||
this.initTimeout = 300000; | ||
|
||
// This takes care of generating status logs on a per-spec basis. By default, Jest only reports at file-level. | ||
// This is strictly optional. | ||
this.registerListeners({ | ||
SpecReporter, | ||
WorkerAssignReporter, | ||
}); | ||
} | ||
} | ||
|
||
module.exports = CustomDetoxEnvironment; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* eslint-disable no-undef */ | ||
|
||
describe('Example', () => { | ||
beforeAll(async () => { | ||
await device.launchApp(); | ||
await device.reloadReactNative(); | ||
}); | ||
|
||
it('isJailBroken', async () => { | ||
await expect(element(by.label('isJailBroken: true'))).toBeVisible(); | ||
}); | ||
|
||
it('canMockLocation', async () => { | ||
await expect(element(by.label('canMockLocation: false'))).toBeVisible(); | ||
}); | ||
|
||
it('trustFall', async () => { | ||
await expect(element(by.label('trustFall: true'))).toBeVisible(); | ||
}); | ||
|
||
it('hookDetected', async () => { | ||
await expect(element(by.label('hookDetected: false'))).toBeVisible(); | ||
}); | ||
|
||
it('isOnExternalStorage', async () => { | ||
await expect(element(by.label('isOnExternalStorage: false'))).toBeVisible(); | ||
}); | ||
|
||
it('AdbEnabled', async () => { | ||
await expect(element(by.label('AdbEnabled: true'))).toBeVisible(); | ||
}); | ||
|
||
it('isDevelopmentSettingsMode', async () => { | ||
await expect( | ||
element(by.label('isDevelopmentSettingsMode: false')), | ||
).toBeVisible(); | ||
}); | ||
|
||
it('isDebuggedMode', async () => { | ||
await expect(element(by.label('isDebuggedMode: true'))).toBeVisible(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.