Skip to content

Commit

Permalink
adding detox configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
syuraj committed Sep 19, 2022
1 parent 2c1b419 commit 42b9d91
Show file tree
Hide file tree
Showing 24 changed files with 1,300 additions and 1,129 deletions.
28 changes: 28 additions & 0 deletions .detoxrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"testRunner": "jest",
"runnerConfig": "e2e/config.json",
"skipLegacyWorkersInjection": true,
"apps": {
"android": {
"type": "android.apk",
"binaryPath": "android/app/build/outputs/apk/unsigned/debug/app-unsigned-debug.apk"
}
},
"configurations": {
"android": {
"device": "emulator",
"app": "android"
},
"android.emu.debug": {
"binaryPath": "android/app/build/outputs/apk/unsigned/debug/app-unsigned-debug.apk",
"build": "cd android && ./gradlew assembleUnsignedDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
"type": "android.emulator",
"name": "emu"
},
"android.emu.release": {
"binaryPath": "android/app/build/outputs/apk/unsigned/debug/app-unsigned-release.apk",
"build": "cd android && ./gradlew assembleUnsignedRelease assembleAndroidTest -DtestBuildType=release && cd ..",
"type": "android.emulator"
}
}
}
20 changes: 15 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
"node": true,
"jest": true
},
"overrides": [
{
"files": ["*.e2e.js"],
"env": {
"detox/detox": true,
"jest": true,
"jest/globals": true
}
}
],
"extends": ["standard", "plugin:prettier/recommended", "@react-native-community"],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly",
"fetch": "readonly"
},
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
Expand Down Expand Up @@ -45,5 +50,10 @@
"quotes": "warn",
"comma-dangle": "off",
"eqeqeq": "off"
},
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly",
"fetch": "readonly"
}
}
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
nodejs 16.13.1
nodejs 16.17.0
java openjdk-15.0.1
10 changes: 10 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ android {
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
}
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

splits {
Expand Down Expand Up @@ -76,7 +78,11 @@ android {
release {
minifyEnabled true
shrinkResources true

proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
// Detox-specific additions to pro-guard
// proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"

firebaseCrashlytics {
nativeSymbolUploadEnabled true
unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib'
Expand Down Expand Up @@ -137,6 +143,10 @@ dependencies {
// required to avoid crash on Android 12 API 31
implementation 'androidx.work:work-runtime:2.7.1'
implementation "androidx.media:media:1.6.0"

androidTestImplementation('com.wix:detox:0.1.1') { transitive = true }
androidTestImplementation 'junit:junit:4.12'
implementation "androidx.annotation:annotation:1.4.0"
}

// Run this once to be able to run the application with BUCK
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Replace "com.example" here and below with your app's package name from the top of MainActivity.java
package com.siristechnology.nepaltodayapp.beta;

import com.wix.detox.Detox;
Expand All @@ -15,18 +14,22 @@
@RunWith(AndroidJUnit4.class)
@LargeTest
public class DetoxTest {
@Rule
// Replace 'MainActivity' with the value of android:name entry in
// 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 = (BuildConfig.DEBUG ? 180 : 60);

Detox.runTests(mActivityRule, detoxConfig);
}
}
}
Binary file removed android/app/src/main/assets/fonts/Entypo.ttf
Binary file not shown.
Binary file removed android/app/src/main/assets/fonts/EvilIcons.ttf
Binary file not shown.
Binary file removed android/app/src/main/assets/fonts/Feather.ttf
Binary file not shown.
Binary file removed android/app/src/main/assets/fonts/Fontisto.ttf
Binary file not shown.
Binary file removed android/app/src/main/assets/fonts/Foundation.ttf
Binary file not shown.
Binary file removed android/app/src/main/assets/fonts/Ionicons.ttf
Binary file not shown.
Binary file removed android/app/src/main/assets/fonts/Octicons.ttf
Binary file not shown.
Binary file removed android/app/src/main/assets/fonts/Roboto.ttf
Binary file not shown.
Binary file removed android/app/src/main/assets/fonts/Roboto_medium.ttf
Binary file not shown.
Binary file not shown.
Binary file removed android/app/src/main/assets/fonts/Zocial.ttf
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
ext {
buildToolsVersion = '30.0.0'
minSdkVersion = 21
compileSdkVersion = 31
compileSdkVersion = 32
targetSdkVersion = 31
supportLibVersion = "28.0.0"
ndkVersion = "20.1.5948944"
Expand Down
9 changes: 9 additions & 0 deletions e2e/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"maxWorkers": 1,
"testEnvironment": "./environment",
"testRunner": "jest-circus/runner",
"testTimeout": 120000,
"testRegex": "\\.e2e\\.js$",
"reporters": ["detox/runners/jest/streamlineReporter"],
"verbose": true
}
19 changes: 19 additions & 0 deletions e2e/environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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
23 changes: 23 additions & 0 deletions e2e/firstTest.e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
describe('Example', () => {
beforeAll(async () => {
await device.launchApp()
})

beforeEach(async () => {
await device.reloadReactNative()
})

it('should have welcome screen', async () => {
await expect(element(by.id('welcome'))).toBeVisible()
})

it('should show hello screen after tap', async () => {
await element(by.id('hello_button')).tap()
await expect(element(by.text('Hello!!!'))).toBeVisible()
})

it('should show world screen after tap', async () => {
await element(by.id('world_button')).tap()
await expect(element(by.text('World!!!'))).toBeVisible()
})
})
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"react-native-fast-image": "^8.3.4",
"react-native-gesture-handler": "~1.10.3",
"react-native-localize": "^2.2.2",
"react-native-pager-view": "^5.0.12",
"react-native-pager-view": "^6.0.0",
"react-native-paper": "5.0.0-rc.5",
"react-native-push-notification": "^8.1.1",
"react-native-reanimated": "~2.1.0",
Expand All @@ -70,14 +70,16 @@
"@react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"babel-plugin-transform-remove-console": "^6.9.4",
"detox": "^19.12.1",
"eslint": "7.14.0",
"eslint-config-prettier": "^6.15.0",
"eslint-config-standard": "^16.0.2",
"eslint-plugin-detox": "^1.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.1.0",
"jest": "^26.6.3",
"jest": "^29.0.3",
"jetifier": "^1.6.3",
"metro-react-native-babel-preset": "^0.64.0",
"prettier-eslint": "^12.0.0",
Expand Down
17 changes: 17 additions & 0 deletions test.detoxrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"testRunner": "jest",
"runnerConfig": "e2e/config.json",
"configurations": {
"android.emu.debug": {
"binaryPath": "android/app/build/outputs/apk/unsigned/debug/app-unsigned-debug.apk",
"build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
"type": "android.emulator",
"name": "emu"
},
"android.emu.release": {
"binaryPath": "android/app/build/outputs/apk/unsigned/debug/app-unsigned-release.apk",
"build": "cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..",
"type": "android.emulator"
}
}
}
Loading

0 comments on commit 42b9d91

Please sign in to comment.