From f538156b9de1a22562762d1e67f6a609d15d6b43 Mon Sep 17 00:00:00 2001 From: Matt Oakes Date: Sat, 16 Mar 2019 19:35:47 +0000 Subject: [PATCH] WIP: Add the required settings to avoid Javscript errors for Android Detox tests --- example/android/app/build.gradle | 2 +- .../java/com/camerarollexample/DetoxTest.java | 24 +++++++++++++++++++ .../android/app/src/main/AndroidManifest.xml | 1 + .../camerarollexample/MainApplication.java | 4 +++- example/e2e/init.js | 2 +- example/e2e/sanityTest.spec.js | 2 +- 6 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 example/android/app/src/androidTest/java/com/camerarollexample/DetoxTest.java diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 3493ce12b..08a6ea3d7 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -99,7 +99,7 @@ android { buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { - applicationId "com.reactnativecommunity.cameraroll.example" + applicationId "com.camerarollexample" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 diff --git a/example/android/app/src/androidTest/java/com/camerarollexample/DetoxTest.java b/example/android/app/src/androidTest/java/com/camerarollexample/DetoxTest.java new file mode 100644 index 000000000..01b32c2c4 --- /dev/null +++ b/example/android/app/src/androidTest/java/com/camerarollexample/DetoxTest.java @@ -0,0 +1,24 @@ +package com.camerarollexample; + +import android.support.test.filters.LargeTest; +import android.support.test.rule.ActivityTestRule; +import android.support.test.runner.AndroidJUnit4; + +import com.wix.detox.Detox; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(AndroidJUnit4.class) +@LargeTest +public class DetoxTest { + + @Rule + public ActivityTestRule mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false); + + @Test + public void runDetoxTests() throws InterruptedException { + Detox.runTests(mActivityRule); + } +} diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index f5e9e0e0b..1bc5806c4 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -3,6 +3,7 @@ + getPackages() { return Arrays.asList( - new MainReactPackage() + new MainReactPackage(), + new CameraRollPackage() ); } diff --git a/example/e2e/init.js b/example/e2e/init.js index d4bea54b4..2308c74cf 100644 --- a/example/e2e/init.js +++ b/example/e2e/init.js @@ -16,7 +16,7 @@ jest.setTimeout(300000); jasmine.getEnv().addReporter(adapter); beforeAll(async () => { - await detox.init(config, {initGlobals: false, launchApp: false}); + await detox.init(config, {launchApp: false}); }); beforeEach(async () => { diff --git a/example/e2e/sanityTest.spec.js b/example/e2e/sanityTest.spec.js index 9b9c248af..0d733e0e4 100644 --- a/example/e2e/sanityTest.spec.js +++ b/example/e2e/sanityTest.spec.js @@ -8,7 +8,7 @@ * @flow */ /* eslint-env jest */ -const {device, expect, element, by} = require('detox'); +/* global device, element, by */ describe('CameraRoll', () => { beforeEach(async () => {