Detox: Avoid/Ignore tests in node_modules (android)

Created on 7 Jun 2018  路  3Comments  路  Source: wix/Detox

Description

In case there are old version tests in the node_module package (react-native-interactable) the new setup with Gradle 3 will make the test compilation fail with
~
error: package android.support.test does not exist
~

The only solution I found was to remove/rename the node_modules/react-native-interactable/lib/android/src/androidTest folder

Is there any way we could tell detox to avoid these folders or modules?
Thank you 馃

Steps to Reproduce

Include react-native-interactable in an app and try to run detox

Detox, Node, Device, Xcode and macOS Versions

  • Detox: 7.4.0
  • React Native: 0.52.0
  • Node: 8.11.0
  • Device: Geny Motion Android 7.1
  • macOS: High Sierra

Device and verbose Detox logs

~~~

Task :react-native-interactable:compileDebugJavaWithJavac
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

Task :react-native-interactable:compileDebugAndroidTestJavaWithJavac FAILED
/Work/clients/current/goin/gitlab/Goin/node_modules/react-native-interactable/lib/android/src/androidTest/java/com/wix/interactable/ExampleInstrumentedTest.java:4: error: package android.support.test does not exist
import android.support.test.InstrumentationRegistry;
^
/Work/clients/current/goin/gitlab/Goin/node_modules/react-native-interactable/lib/android/src/androidTest/java/com/wix/interactable/ExampleInstrumentedTest.java:5: error: package android.support.test.runner does not exist
import android.support.test.runner.AndroidJUnit4;
^
/Work/clients/current/goin/gitlab/Goin/node_modules/react-native-interactable/lib/android/src/androidTest/java/com/wix/interactable/ExampleInstrumentedTest.java:7: error: package org.junit does not exist
import org.junit.Test;
^
/Work/clients/current/goin/gitlab/Goin/node_modules/react-native-interactable/lib/android/src/androidTest/java/com/wix/interactable/ExampleInstrumentedTest.java:8: error: package org.junit.runner does not exist
import org.junit.runner.RunWith;
^
/Work/clients/current/goin/gitlab/Goin/node_modules/react-native-interactable/lib/android/src/androidTest/java/com/wix/interactable/ExampleInstrumentedTest.java:10: error: package org.junit does not exist
import static org.junit.Assert.*;
^
/Work/clients/current/goin/gitlab/Goin/node_modules/react-native-interactable/lib/android/src/androidTest/java/com/wix/interactable/ExampleInstrumentedTest.java:17: error: cannot find symbol
@RunWith(AndroidJUnit4.class)
^
symbol: class RunWith
/Work/clients/current/goin/gitlab/Goin/node_modules/react-native-interactable/lib/android/src/androidTest/java/com/wix/interactable/ExampleInstrumentedTest.java:19: error: cannot find symbol
@Test
^
symbol: class Test
location: class ExampleInstrumentedTest
/Work/clients/current/goin/gitlab/Goin/node_modules/react-native-interactable/lib/android/src/androidTest/java/com/wix/interactable/ExampleInstrumentedTest.java:22: error: cannot find symbol
Context appContext = InstrumentationRegistry.getTargetContext();
^
symbol: variable InstrumentationRegistry
location: class ExampleInstrumentedTest
/Work/clients/current/goin/gitlab/Goin/node_modules/react-native-interactable/lib/android/src/androidTest/java/com/wix/interactable/ExampleInstrumentedTest.java:24: error: cannot find symbol
assertEquals("com.wix.interactable", appContext.getPackageName());
^
symbol: method assertEquals(String,String)
location: class ExampleInstrumentedTest
9 errors

~~~

questiostack overflow

Most helpful comment

Gradle can be configured to run tasks on specific projects.
Prefixing the project name (i.e. app:) will only run that specific task in the project and ignore same task in other projects.

```
./gradlew assembleDebug app:assembleDebugAndroidTest

All 3 comments

Gradle can be configured to run tasks on specific projects.
Prefixing the project name (i.e. app:) will only run that specific task in the project and ignore same task in other projects.

```
./gradlew assembleDebug app:assembleDebugAndroidTest

馃檧you are my hero 馃
Thanks!

We use the issue tracker exclusively for bug reports and feature requests. This issue appears to be a general usage or support question. Instead, please ask a question on Stack Overflow with the detox tag.

Was this page helpful?
0 / 5 - 0 ratings