WIP: Add the required settings to avoid Javscript errors for Android Detox tests

This commit is contained in:
Matt Oakes 2019-03-16 19:35:47 +00:00
parent 9540b013d3
commit f538156b9d
6 changed files with 31 additions and 4 deletions

View File

@ -99,7 +99,7 @@ android {
buildToolsVersion rootProject.ext.buildToolsVersion buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig { defaultConfig {
applicationId "com.reactnativecommunity.cameraroll.example" applicationId "com.camerarollexample"
minSdkVersion rootProject.ext.minSdkVersion minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1 versionCode 1

View File

@ -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<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
@Test
public void runDetoxTests() throws InterruptedException {
Detox.runTests(mActivityRule);
}
}

View File

@ -3,6 +3,7 @@
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application <application
android:name=".MainApplication" android:name=".MainApplication"

View File

@ -2,6 +2,7 @@ package com.camerarollexample;
import android.app.Application; import android.app.Application;
import com.reactnativecommunity.cameraroll.CameraRollPackage;
import com.facebook.react.ReactApplication; import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage; import com.facebook.react.ReactPackage;
@ -22,7 +23,8 @@ public class MainApplication extends Application implements ReactApplication {
@Override @Override
protected List<ReactPackage> getPackages() { protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList( return Arrays.<ReactPackage>asList(
new MainReactPackage() new MainReactPackage(),
new CameraRollPackage()
); );
} }

View File

@ -16,7 +16,7 @@ jest.setTimeout(300000);
jasmine.getEnv().addReporter(adapter); jasmine.getEnv().addReporter(adapter);
beforeAll(async () => { beforeAll(async () => {
await detox.init(config, {initGlobals: false, launchApp: false}); await detox.init(config, {launchApp: false});
}); });
beforeEach(async () => { beforeEach(async () => {

View File

@ -8,7 +8,7 @@
* @flow * @flow
*/ */
/* eslint-env jest */ /* eslint-env jest */
const {device, expect, element, by} = require('detox'); /* global device, element, by */
describe('CameraRoll', () => { describe('CameraRoll', () => {
beforeEach(async () => { beforeEach(async () => {