expo-test-runner 0.0.10 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +2 -28
- package/build/BundlerController.js +7 -8
- package/build/BundlerController.js.map +1 -1
- package/build/ConfigReader.js +1 -1
- package/build/ConfigReader.js.map +1 -1
- package/build/Paths.js +1 -1
- package/build/Paths.js.map +1 -1
- package/build/TemplateEvaluator.js +6 -2
- package/build/TemplateEvaluator.js.map +1 -1
- package/build/TemplateFile.js +9 -5
- package/build/TemplateFile.js.map +1 -1
- package/build/TemplateProject.d.ts +25 -0
- package/build/TemplateProject.js +167 -0
- package/build/TemplateProject.js.map +1 -0
- package/build/Utils.js +4 -4
- package/build/Utils.js.map +1 -1
- package/build/commands/CreateProject.js +3 -3
- package/build/commands/CreateProject.js.map +1 -1
- package/build/commands/RunTest.js +8 -4
- package/build/commands/RunTest.js.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/registerCommand.js +6 -3
- package/build/registerCommand.js.map +1 -1
- package/package.json +26 -21
- package/src/BundlerController.ts +2 -2
- package/src/TemplateProject.ts +208 -0
- package/src/Utils.ts +2 -2
- package/src/commands/CreateProject.ts +2 -2
- package/src/commands/RunTest.ts +2 -2
- package/src/index.ts +1 -1
- package/src/registerCommand.ts +1 -1
- package/templates/detox/android/app/build.gradle +202 -24
- package/templates/detox/android/app/src/androidTest/java/com/testrunner/DetoxTest.java +79 -18
- package/templates/detox/android/app/src/main/java/com/testrunner/MainApplication.java +129 -0
- package/templates/detox/android/build.gradle +34 -17
- package/templates/detox/ios/devcliente2e/main.m +31 -0
- package/tsconfig.json +1 -1
- package/.prettierrc +0 -10
- package/build/Platform.ds.d.ts +0 -4
- package/build/Platform.ds.js +0 -9
- package/build/Platform.ds.js.map +0 -1
- package/build/ProjectFile.d.ts +0 -0
- package/build/ProjectFile.js +0 -2
- package/build/ProjectFile.js.map +0 -1
- package/build/TemplateParser.d.ts +0 -6
- package/build/TemplateParser.js +0 -37
- package/build/TemplateParser.js.map +0 -1
- package/build/commands/create-project.d.ts +0 -3
- package/build/commands/create-project.js +0 -12
- package/build/commands/create-project.js.map +0 -1
- package/build/presets/DetoxTemplate.d.ts +0 -13
- package/build/presets/DetoxTemplate.js +0 -79
- package/build/presets/DetoxTemplate.js.map +0 -1
- package/build/presets/PresetTemplate.d.ts +0 -25
- package/build/presets/PresetTemplate.js +0 -147
- package/build/presets/PresetTemplate.js.map +0 -1
- package/src/presets/DetoxTemplate.ts +0 -94
- package/src/presets/PresetTemplate.ts +0 -171
- package/templates/basic/android/app/BUCK +0 -55
- package/templates/basic/android/app/build.gradle +0 -188
- package/templates/basic/android/app/build_defs.bzl +0 -19
- package/templates/basic/android/app/debug.keystore +0 -0
- package/templates/basic/android/app/proguard-rules.pro +0 -10
- package/templates/basic/android/app/src/main/AndroidManifest.xml +0 -16
- package/templates/basic/android/app/src/main/java/com/testrunner/MainActivity.java +0 -28
- package/templates/basic/android/app/src/main/java/com/testrunner/MainApplication.java +0 -57
- package/templates/basic/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/templates/basic/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/templates/basic/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/templates/basic/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/templates/basic/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/templates/basic/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/templates/basic/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/templates/basic/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/templates/basic/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/templates/basic/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/templates/basic/android/app/src/main/res/values/styles.xml +0 -14
- package/templates/basic/android/build.gradle +0 -38
- package/templates/basic/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/templates/basic/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/templates/basic/android/gradle.properties +0 -26
- package/templates/basic/android/gradlew +0 -183
- package/templates/basic/android/gradlew.bat +0 -103
- package/templates/basic/android/settings.gradle +0 -10
- package/templates/basic/babel.config.js +0 -6
- package/templates/basic/ios/Podfile +0 -37
- package/templates/basic/ios/project.yml +0 -10
- package/templates/basic/ios/src/AppDelegate.h +0 -9
- package/templates/basic/ios/src/AppDelegate.m +0 -62
- package/templates/basic/ios/src/Images.xcassets/AppIcon.appiconset/Contents.json +0 -38
- package/templates/basic/ios/src/Images.xcassets/Contents.json +0 -6
- package/templates/basic/ios/src/Info.plist +0 -55
- package/templates/basic/ios/src/LaunchScreen.storyboard +0 -47
- package/templates/basic/ios/src/dummy.swift +0 -0
- package/templates/basic/ios/src/main.m +0 -9
- package/templates/basic/package.json +0 -37
- package/templates/basic/tsconfig.json +0 -6
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
apply plugin: "com.android.application"
|
|
2
2
|
|
|
3
3
|
import com.android.build.OutputFile
|
|
4
|
+
import org.apache.tools.ant.taskdefs.condition.Os
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
|
|
@@ -77,7 +78,19 @@ import com.android.build.OutputFile
|
|
|
77
78
|
* ]
|
|
78
79
|
*/
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath()
|
|
82
|
+
|
|
83
|
+
def reactNativeRoot = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath()
|
|
84
|
+
|
|
85
|
+
project.ext.react = [
|
|
86
|
+
entryFile: ["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android"].execute(null, rootDir).text.trim(),
|
|
87
|
+
enableHermes: (findProperty('expo.jsEngine') ?: "jsc") == "hermes",
|
|
88
|
+
hermesCommand: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc",
|
|
89
|
+
cliPath: "${reactNativeRoot}/cli.js",
|
|
90
|
+
composeSourceMapsPath: "${reactNativeRoot}/scripts/compose-source-maps.js",
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
apply from: new File(reactNativeRoot, "react.gradle")
|
|
81
94
|
|
|
82
95
|
/**
|
|
83
96
|
* Set this to true to create two separate APKs instead of one:
|
|
@@ -92,7 +105,7 @@ def enableSeparateBuildPerCPUArchitecture = false
|
|
|
92
105
|
/**
|
|
93
106
|
* Run Proguard to shrink the Java bytecode in release builds.
|
|
94
107
|
*/
|
|
95
|
-
def enableProguardInReleaseBuilds = false
|
|
108
|
+
def enableProguardInReleaseBuilds = (findProperty('android.enableProguardInReleaseBuilds') ?: false).toBoolean()
|
|
96
109
|
|
|
97
110
|
/**
|
|
98
111
|
* The preferred build flavor of JavaScriptCore.
|
|
@@ -107,31 +120,117 @@ def enableProguardInReleaseBuilds = false
|
|
|
107
120
|
*/
|
|
108
121
|
def jscFlavor = 'org.webkit:android-jsc:+'
|
|
109
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Whether to enable the Hermes VM.
|
|
125
|
+
*
|
|
126
|
+
* This should be set on project.ext.react and that value will be read here. If it is not set
|
|
127
|
+
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
|
|
128
|
+
* and the benefits of using Hermes will therefore be sharply reduced.
|
|
129
|
+
*/
|
|
130
|
+
def enableHermes = project.ext.react.get("enableHermes", false);
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Architectures to build native code for.
|
|
134
|
+
*/
|
|
135
|
+
def reactNativeArchitectures() {
|
|
136
|
+
def value = project.getProperties().get("reactNativeArchitectures")
|
|
137
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
138
|
+
}
|
|
110
139
|
|
|
111
140
|
android {
|
|
112
|
-
|
|
141
|
+
ndkVersion rootProject.ext.ndkVersion
|
|
113
142
|
|
|
114
|
-
|
|
115
|
-
sourceCompatibility JavaVersion.VERSION_1_8
|
|
116
|
-
targetCompatibility JavaVersion.VERSION_1_8
|
|
117
|
-
}
|
|
143
|
+
compileSdkVersion rootProject.ext.compileSdkVersion
|
|
118
144
|
|
|
119
145
|
defaultConfig {
|
|
120
|
-
applicationId
|
|
146
|
+
applicationId 'com.testrunner'
|
|
121
147
|
minSdkVersion rootProject.ext.minSdkVersion
|
|
122
148
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
|
123
149
|
versionCode 1
|
|
124
|
-
versionName "1.0"
|
|
150
|
+
versionName "1.0.0"
|
|
151
|
+
testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type
|
|
152
|
+
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
|
|
153
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
125
154
|
|
|
126
|
-
|
|
127
|
-
|
|
155
|
+
if (isNewArchitectureEnabled()) {
|
|
156
|
+
// We configure the NDK build only if you decide to opt-in for the New Architecture.
|
|
157
|
+
externalNativeBuild {
|
|
158
|
+
ndkBuild {
|
|
159
|
+
arguments "APP_PLATFORM=android-21",
|
|
160
|
+
"APP_STL=c++_shared",
|
|
161
|
+
"NDK_TOOLCHAIN_VERSION=clang",
|
|
162
|
+
"GENERATED_SRC_DIR=$buildDir/generated/source",
|
|
163
|
+
"PROJECT_BUILD_DIR=$buildDir",
|
|
164
|
+
"REACT_ANDROID_DIR=${reactNativeRoot}/ReactAndroid",
|
|
165
|
+
"REACT_ANDROID_BUILD_DIR=${reactNativeRoot}/ReactAndroid/build",
|
|
166
|
+
"NODE_MODULES_DIR=$rootDir/../node_modules"
|
|
167
|
+
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
|
|
168
|
+
cppFlags "-std=c++17"
|
|
169
|
+
// Make sure this target name is the same you specify inside the
|
|
170
|
+
// src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
|
|
171
|
+
targets "devcliente2e_appmodules"
|
|
172
|
+
|
|
173
|
+
// Fix for windows limit on number of character in file paths and in command lines
|
|
174
|
+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
|
175
|
+
arguments "NDK_APP_SHORT_COMMANDS=true"
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (!enableSeparateBuildPerCPUArchitecture) {
|
|
180
|
+
ndk {
|
|
181
|
+
abiFilters (*reactNativeArchitectures())
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (isNewArchitectureEnabled()) {
|
|
188
|
+
// We configure the NDK build only if you decide to opt-in for the New Architecture.
|
|
189
|
+
externalNativeBuild {
|
|
190
|
+
ndkBuild {
|
|
191
|
+
path "$projectDir/src/main/jni/Android.mk"
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
|
|
195
|
+
def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
|
|
196
|
+
dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
|
|
197
|
+
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
|
|
198
|
+
into("$buildDir/react-ndk/exported")
|
|
199
|
+
}
|
|
200
|
+
def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
|
|
201
|
+
dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
|
|
202
|
+
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
|
|
203
|
+
into("$buildDir/react-ndk/exported")
|
|
204
|
+
}
|
|
205
|
+
afterEvaluate {
|
|
206
|
+
// If you wish to add a custom TurboModule or component locally,
|
|
207
|
+
// you should uncomment this line.
|
|
208
|
+
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
|
|
209
|
+
preDebugBuild.dependsOn(packageReactNdkDebugLibs)
|
|
210
|
+
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
|
|
211
|
+
|
|
212
|
+
// Due to a bug inside AGP, we have to explicitly set a dependency
|
|
213
|
+
// between configureNdkBuild* tasks and the preBuild tasks.
|
|
214
|
+
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
|
|
215
|
+
configureNdkBuildRelease.dependsOn(preReleaseBuild)
|
|
216
|
+
configureNdkBuildDebug.dependsOn(preDebugBuild)
|
|
217
|
+
reactNativeArchitectures().each { architecture ->
|
|
218
|
+
tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
|
|
219
|
+
dependsOn("preDebugBuild")
|
|
220
|
+
}
|
|
221
|
+
tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
|
|
222
|
+
dependsOn("preReleaseBuild")
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
128
226
|
}
|
|
227
|
+
|
|
129
228
|
splits {
|
|
130
229
|
abi {
|
|
131
230
|
reset()
|
|
132
231
|
enable enableSeparateBuildPerCPUArchitecture
|
|
133
232
|
universalApk false // If true, also generate a universal APK
|
|
134
|
-
include
|
|
233
|
+
include (*reactNativeArchitectures())
|
|
135
234
|
}
|
|
136
235
|
}
|
|
137
236
|
signingConfigs {
|
|
@@ -152,8 +251,6 @@ android {
|
|
|
152
251
|
signingConfig signingConfigs.debug
|
|
153
252
|
minifyEnabled enableProguardInReleaseBuilds
|
|
154
253
|
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
|
155
|
-
// Detox-specific additions to pro-guard
|
|
156
|
-
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
|
|
157
254
|
}
|
|
158
255
|
}
|
|
159
256
|
|
|
@@ -173,36 +270,117 @@ android {
|
|
|
173
270
|
}
|
|
174
271
|
}
|
|
175
272
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
273
|
+
// Apply static values from `gradle.properties` to the `android.packagingOptions`
|
|
274
|
+
// Accepts values in comma delimited lists, example:
|
|
275
|
+
// android.packagingOptions.pickFirsts=/LICENSE,**/picasa.ini
|
|
276
|
+
["pickFirsts", "excludes", "merges", "doNotStrip"].each { prop ->
|
|
277
|
+
// Split option: 'foo,bar' -> ['foo', 'bar']
|
|
278
|
+
def options = (findProperty("android.packagingOptions.$prop") ?: "").split(",");
|
|
279
|
+
// Trim all elements in place.
|
|
280
|
+
for (i in 0..<options.size()) options[i] = options[i].trim();
|
|
281
|
+
// `[] - ""` is essentially `[""].filter(Boolean)` removing all empty strings.
|
|
282
|
+
options -= ""
|
|
283
|
+
|
|
284
|
+
if (options.length > 0) {
|
|
285
|
+
println "android.packagingOptions.$prop += $options ($options.length)"
|
|
286
|
+
// Ex: android.packagingOptions.pickFirsts += '**/SCCS/**'
|
|
287
|
+
options.each {
|
|
288
|
+
android.packagingOptions[prop] += it
|
|
182
289
|
}
|
|
183
290
|
}
|
|
184
291
|
}
|
|
185
292
|
|
|
186
293
|
dependencies {
|
|
187
294
|
implementation fileTree(dir: "libs", include: ["*.jar"])
|
|
295
|
+
|
|
188
296
|
//noinspection GradleDynamicVersion
|
|
189
297
|
implementation "com.facebook.react:react-native:+" // From node_modules
|
|
298
|
+
|
|
299
|
+
def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
|
|
300
|
+
def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
|
|
301
|
+
def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
|
|
302
|
+
def frescoVersion = rootProject.ext.frescoVersion
|
|
303
|
+
|
|
304
|
+
// If your app supports Android versions before Ice Cream Sandwich (API level 14)
|
|
305
|
+
if (isGifEnabled || isWebpEnabled) {
|
|
306
|
+
implementation "com.facebook.fresco:fresco:${frescoVersion}"
|
|
307
|
+
implementation "com.facebook.fresco:imagepipeline-okhttp3:${frescoVersion}"
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (isGifEnabled) {
|
|
311
|
+
// For animated gif support
|
|
312
|
+
implementation "com.facebook.fresco:animated-gif:${frescoVersion}"
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (isWebpEnabled) {
|
|
316
|
+
// For webp support
|
|
317
|
+
implementation "com.facebook.fresco:webpsupport:${frescoVersion}"
|
|
318
|
+
if (isWebpAnimatedEnabled) {
|
|
319
|
+
// Animated webp support
|
|
320
|
+
implementation "com.facebook.fresco:animated-webp:${frescoVersion}"
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
190
324
|
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
|
|
191
|
-
|
|
192
|
-
|
|
325
|
+
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
|
|
326
|
+
exclude group:'com.facebook.fbjni'
|
|
327
|
+
}
|
|
328
|
+
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
|
|
329
|
+
exclude group:'com.facebook.flipper'
|
|
330
|
+
exclude group:'com.squareup.okhttp3', module:'okhttp'
|
|
331
|
+
}
|
|
332
|
+
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
|
|
333
|
+
exclude group:'com.facebook.flipper'
|
|
334
|
+
}
|
|
193
335
|
|
|
336
|
+
androidTestImplementation "androidx.test.ext:junit:1.1.3"
|
|
337
|
+
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.0.4"
|
|
194
338
|
androidTestImplementation('com.wix:detox:+') {
|
|
195
339
|
// Fix detox + react-native-screens error
|
|
196
340
|
// https://github.com/wix/Detox/issues/2848#issuecomment-874803711
|
|
197
341
|
exclude group: 'com.google.android.material'
|
|
198
342
|
}
|
|
343
|
+
|
|
344
|
+
if (enableHermes) {
|
|
345
|
+
//noinspection GradleDynamicVersion
|
|
346
|
+
implementation("com.facebook.react:hermes-engine:+") { // From node_modules
|
|
347
|
+
exclude group:'com.facebook.fbjni'
|
|
348
|
+
}
|
|
349
|
+
} else {
|
|
350
|
+
implementation jscFlavor
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if (isNewArchitectureEnabled()) {
|
|
355
|
+
// If new architecture is enabled, we let you build RN from source
|
|
356
|
+
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
|
|
357
|
+
// This will be applied to all the imported transtitive dependency.
|
|
358
|
+
configurations.all {
|
|
359
|
+
resolutionStrategy.dependencySubstitution {
|
|
360
|
+
substitute(module("com.facebook.react:react-native"))
|
|
361
|
+
.using(project(":ReactAndroid"))
|
|
362
|
+
.because("On New Architecture we're building React Native from source")
|
|
363
|
+
substitute(module("com.facebook.react:hermes-engine"))
|
|
364
|
+
.using(project(":ReactAndroid:hermes-engine"))
|
|
365
|
+
.because("On New Architecture we're building Hermes from source")
|
|
366
|
+
}
|
|
367
|
+
}
|
|
199
368
|
}
|
|
200
369
|
|
|
201
370
|
// Run this once to be able to run the application with BUCK
|
|
202
371
|
// puts all compile dependencies into folder libs for BUCK to use
|
|
203
372
|
task copyDownloadableDepsToLibs(type: Copy) {
|
|
204
|
-
from configurations.
|
|
373
|
+
from configurations.implementation
|
|
205
374
|
into 'libs'
|
|
206
375
|
}
|
|
207
376
|
|
|
208
|
-
apply from:
|
|
377
|
+
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
|
|
378
|
+
applyNativeModulesAppBuildGradle(project)
|
|
379
|
+
|
|
380
|
+
def isNewArchitectureEnabled() {
|
|
381
|
+
// To opt-in for the New Architecture, you can either:
|
|
382
|
+
// - Set `newArchEnabled` to true inside the `gradle.properties` file
|
|
383
|
+
// - Invoke gradle with `-newArchEnabled=true`
|
|
384
|
+
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
|
|
385
|
+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
386
|
+
}
|
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
package com.testrunner;
|
|
2
2
|
|
|
3
|
+
import static androidx.test.espresso.Espresso.onView;
|
|
4
|
+
import static androidx.test.espresso.matcher.ViewMatchers.isRoot;
|
|
5
|
+
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
|
|
6
|
+
|
|
7
|
+
import android.app.Activity;
|
|
8
|
+
import android.content.Context;
|
|
9
|
+
import android.content.ContextWrapper;
|
|
10
|
+
import android.view.View;
|
|
11
|
+
import android.view.ViewGroup;
|
|
12
|
+
|
|
13
|
+
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
14
|
+
import androidx.test.filters.LargeTest;
|
|
15
|
+
import androidx.test.rule.ActivityTestRule;
|
|
16
|
+
|
|
17
|
+
import com.facebook.react.ReactApplication;
|
|
18
|
+
import com.facebook.react.ReactNativeHost;
|
|
3
19
|
import com.wix.detox.Detox;
|
|
4
20
|
import com.wix.detox.config.DetoxConfig;
|
|
5
21
|
|
|
@@ -7,25 +23,70 @@ import org.junit.Rule;
|
|
|
7
23
|
import org.junit.Test;
|
|
8
24
|
import org.junit.runner.RunWith;
|
|
9
25
|
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
26
|
+
import expo.modules.devlauncher.DevLauncherController;
|
|
27
|
+
import expo.modules.devlauncher.launcher.DevLauncherActivity;
|
|
28
|
+
import expo.modules.devmenu.DevMenuManager;
|
|
29
|
+
|
|
30
|
+
// We need this class to pass dev launcher host to detox.
|
|
31
|
+
// Otherwise it won't detect that the app has been started.
|
|
32
|
+
class ReactNativeHolder extends ContextWrapper implements ReactApplication {
|
|
33
|
+
public ReactNativeHolder(Context base) {
|
|
34
|
+
super(base);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@Override
|
|
38
|
+
public ReactNativeHost getReactNativeHost() {
|
|
39
|
+
return DevLauncherController.getInstance().getDevClientHost();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
class DevClientDetoxHelper {
|
|
44
|
+
public static Activity getCurrentActivity() {
|
|
45
|
+
final Activity[] activity = new Activity[1];
|
|
46
|
+
|
|
47
|
+
onView(isRoot()).check((view, noViewFoundException) -> {
|
|
48
|
+
|
|
49
|
+
View checkedView = view;
|
|
50
|
+
|
|
51
|
+
while (checkedView instanceof ViewGroup && ((ViewGroup) checkedView).getChildCount() > 0) {
|
|
52
|
+
|
|
53
|
+
checkedView = ((ViewGroup) checkedView).getChildAt(0);
|
|
54
|
+
|
|
55
|
+
if (checkedView.getContext() instanceof Activity) {
|
|
56
|
+
activity[0] = (Activity) checkedView.getContext();
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return activity[0];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public static void openMenu() throws InterruptedException {
|
|
65
|
+
getInstrumentation().waitForIdleSync();
|
|
66
|
+
Activity activity = getCurrentActivity();
|
|
67
|
+
int counter = 10;
|
|
68
|
+
while (counter-- > 0 && activity == null) {
|
|
69
|
+
Thread.sleep(100);
|
|
70
|
+
activity = getCurrentActivity();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
DevMenuManager.INSTANCE.openMenu(activity, null);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
13
76
|
|
|
14
77
|
@RunWith(AndroidJUnit4.class)
|
|
15
78
|
@LargeTest
|
|
16
79
|
public class DetoxTest {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
}
|
|
80
|
+
@Rule
|
|
81
|
+
public ActivityTestRule<DevLauncherActivity> mActivityRule = new ActivityTestRule<>(DevLauncherActivity.class, false, false);
|
|
82
|
+
|
|
83
|
+
@Test
|
|
84
|
+
public void runDetoxTests() {
|
|
85
|
+
DetoxConfig detoxConfig = new DetoxConfig();
|
|
86
|
+
detoxConfig.idlePolicyConfig.masterTimeoutSec = 90;
|
|
87
|
+
detoxConfig.rnContextLoadTimeoutSec = 180;
|
|
88
|
+
|
|
89
|
+
ReactNativeHolder reactNativeHolder = new ReactNativeHolder(getInstrumentation().getTargetContext().getApplicationContext());
|
|
90
|
+
Detox.runTests(mActivityRule, reactNativeHolder, detoxConfig);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
package com.testrunner;
|
|
2
|
+
|
|
3
|
+
import android.app.Application;
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import android.content.res.Configuration;
|
|
6
|
+
import androidx.annotation.NonNull;
|
|
7
|
+
import androidx.annotation.Nullable;
|
|
8
|
+
|
|
9
|
+
import com.facebook.react.PackageList;
|
|
10
|
+
import com.facebook.react.ReactApplication;
|
|
11
|
+
import com.facebook.react.ReactInstanceManager;
|
|
12
|
+
import com.facebook.react.ReactNativeHost;
|
|
13
|
+
import com.facebook.react.ReactPackage;
|
|
14
|
+
import com.facebook.react.config.ReactFeatureFlags;
|
|
15
|
+
import com.facebook.soloader.SoLoader;
|
|
16
|
+
import com.testrunner.newarchitecture.MainApplicationReactNativeHost;
|
|
17
|
+
|
|
18
|
+
import expo.interfaces.devmenu.DevMenuPreferencesInterface;
|
|
19
|
+
import expo.modules.ApplicationLifecycleDispatcher;
|
|
20
|
+
import expo.modules.ReactNativeHostWrapper;
|
|
21
|
+
import expo.modules.devmenu.DevMenuDefaultPreferences;
|
|
22
|
+
import expo.modules.devmenu.DevMenuManager;
|
|
23
|
+
import expo.modules.devmenu.tests.DevMenuTestInterceptor;
|
|
24
|
+
|
|
25
|
+
import java.lang.reflect.InvocationTargetException;
|
|
26
|
+
import java.util.List;
|
|
27
|
+
|
|
28
|
+
public class MainApplication extends Application implements ReactApplication {
|
|
29
|
+
private final ReactNativeHost mReactNativeHost = new ReactNativeHostWrapper(
|
|
30
|
+
this,
|
|
31
|
+
new ReactNativeHost(this) {
|
|
32
|
+
@Override
|
|
33
|
+
public boolean getUseDeveloperSupport() {
|
|
34
|
+
return BuildConfig.DEBUG;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@Override
|
|
38
|
+
protected List<ReactPackage> getPackages() {
|
|
39
|
+
@SuppressWarnings("UnnecessaryLocalVariable")
|
|
40
|
+
List<ReactPackage> packages = new PackageList(this).getPackages();
|
|
41
|
+
// Packages that cannot be autolinked yet can be added manually here, for example:
|
|
42
|
+
// packages.add(new MyReactNativePackage());
|
|
43
|
+
return packages;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Override
|
|
47
|
+
protected String getJSMainModuleName() {
|
|
48
|
+
return "index";
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
private final ReactNativeHost mNewArchitectureNativeHost =
|
|
53
|
+
new ReactNativeHostWrapper(this, new MainApplicationReactNativeHost(this));
|
|
54
|
+
|
|
55
|
+
@Override
|
|
56
|
+
public ReactNativeHost getReactNativeHost() {
|
|
57
|
+
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
|
|
58
|
+
return mNewArchitectureNativeHost;
|
|
59
|
+
} else {
|
|
60
|
+
return mReactNativeHost;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@Override
|
|
65
|
+
public void onCreate() {
|
|
66
|
+
super.onCreate();
|
|
67
|
+
// If you opted-in for the New Architecture, we enable the TurboModule system
|
|
68
|
+
ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
|
|
69
|
+
SoLoader.init(this, /* native exopackage */ false);
|
|
70
|
+
|
|
71
|
+
DevMenuManager.INSTANCE.setTestInterceptor(new DevMenuTestInterceptor() {
|
|
72
|
+
@Nullable
|
|
73
|
+
@Override
|
|
74
|
+
public DevMenuPreferencesInterface overrideSettings() {
|
|
75
|
+
return new DevMenuDefaultPreferences() {
|
|
76
|
+
@Override
|
|
77
|
+
public boolean getShowsAtLaunch() {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@Override
|
|
82
|
+
public boolean isOnboardingFinished() {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
|
|
90
|
+
ApplicationLifecycleDispatcher.onApplicationCreate(this);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@Override
|
|
94
|
+
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
|
95
|
+
super.onConfigurationChanged(newConfig);
|
|
96
|
+
ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
|
|
101
|
+
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
|
|
102
|
+
*
|
|
103
|
+
* @param context
|
|
104
|
+
* @param reactInstanceManager
|
|
105
|
+
*/
|
|
106
|
+
private static void initializeFlipper(
|
|
107
|
+
Context context, ReactInstanceManager reactInstanceManager) {
|
|
108
|
+
if (BuildConfig.DEBUG) {
|
|
109
|
+
try {
|
|
110
|
+
/*
|
|
111
|
+
We use reflection here to pick up the class that initializes Flipper,
|
|
112
|
+
since Flipper library is not available in release mode
|
|
113
|
+
*/
|
|
114
|
+
Class<?> aClass = Class.forName("com.testrunner.ReactNativeFlipper");
|
|
115
|
+
aClass
|
|
116
|
+
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
|
|
117
|
+
.invoke(null, context, reactInstanceManager);
|
|
118
|
+
} catch (ClassNotFoundException e) {
|
|
119
|
+
e.printStackTrace();
|
|
120
|
+
} catch (NoSuchMethodException e) {
|
|
121
|
+
e.printStackTrace();
|
|
122
|
+
} catch (IllegalAccessException e) {
|
|
123
|
+
e.printStackTrace();
|
|
124
|
+
} catch (InvocationTargetException e) {
|
|
125
|
+
e.printStackTrace();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -1,21 +1,34 @@
|
|
|
1
|
+
import org.apache.tools.ant.taskdefs.condition.Os
|
|
2
|
+
|
|
1
3
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
|
2
4
|
|
|
3
5
|
buildscript {
|
|
4
6
|
ext {
|
|
5
|
-
buildToolsVersion =
|
|
6
|
-
minSdkVersion = 21
|
|
7
|
-
compileSdkVersion =
|
|
8
|
-
targetSdkVersion =
|
|
9
|
-
|
|
7
|
+
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '31.0.0'
|
|
8
|
+
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '21')
|
|
9
|
+
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '31')
|
|
10
|
+
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '31')
|
|
11
|
+
if (findProperty('android.kotlinVersion')) {
|
|
12
|
+
kotlinVersion = findProperty('android.kotlinVersion')
|
|
13
|
+
}
|
|
14
|
+
frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0'
|
|
15
|
+
|
|
16
|
+
if (System.properties['os.arch'] == 'aarch64') {
|
|
17
|
+
// For M1 Users we need to use the NDK 24 which added support for aarch64
|
|
18
|
+
ndkVersion = '24.0.8215888'
|
|
19
|
+
} else {
|
|
20
|
+
// Otherwise we default to the side-by-side NDK version from AGP.
|
|
21
|
+
ndkVersion = '21.4.7075529'
|
|
22
|
+
}
|
|
10
23
|
}
|
|
11
24
|
repositories {
|
|
12
25
|
google()
|
|
13
|
-
|
|
26
|
+
mavenCentral()
|
|
14
27
|
}
|
|
15
28
|
dependencies {
|
|
16
|
-
classpath(
|
|
17
|
-
|
|
18
|
-
classpath
|
|
29
|
+
classpath('com.android.tools.build:gradle:7.1.1')
|
|
30
|
+
classpath('com.facebook.react:react-native-gradle-plugin')
|
|
31
|
+
classpath('de.undercouch:gradle-download-task:5.0.1')
|
|
19
32
|
// NOTE: Do not place your application dependencies here; they belong
|
|
20
33
|
// in the individual module build.gradle files
|
|
21
34
|
}
|
|
@@ -24,23 +37,27 @@ buildscript {
|
|
|
24
37
|
allprojects {
|
|
25
38
|
repositories {
|
|
26
39
|
mavenLocal()
|
|
40
|
+
maven {
|
|
41
|
+
// All of Detox' artifacts are provided via the npm module
|
|
42
|
+
url "$rootDir/../node_modules/detox/Detox-android"
|
|
43
|
+
}
|
|
27
44
|
maven {
|
|
28
45
|
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
|
29
|
-
url("
|
|
46
|
+
url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android'))
|
|
30
47
|
}
|
|
31
48
|
maven {
|
|
32
49
|
// Android JSC is installed from npm
|
|
33
|
-
url("
|
|
50
|
+
url(new File(['node', '--print', "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), '../dist'))
|
|
34
51
|
}
|
|
35
52
|
|
|
36
53
|
google()
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
//
|
|
40
|
-
|
|
54
|
+
mavenCentral {
|
|
55
|
+
// We don't want to fetch react-native from Maven Central as there are
|
|
56
|
+
// older versions over there.
|
|
57
|
+
content {
|
|
58
|
+
excludeGroup 'com.facebook.react'
|
|
59
|
+
}
|
|
41
60
|
}
|
|
42
|
-
|
|
43
|
-
jcenter()
|
|
44
61
|
maven { url 'https://www.jitpack.io' }
|
|
45
62
|
}
|
|
46
63
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#import <UIKit/UIKit.h>
|
|
2
|
+
|
|
3
|
+
#import "AppDelegate.h"
|
|
4
|
+
|
|
5
|
+
@import EXDevMenu;
|
|
6
|
+
|
|
7
|
+
@interface DevMenuDetoxTestInterceptor : NSObject<DevMenuTestInterceptor>
|
|
8
|
+
|
|
9
|
+
@end
|
|
10
|
+
|
|
11
|
+
@implementation DevMenuDetoxTestInterceptor
|
|
12
|
+
|
|
13
|
+
- (BOOL)isOnboardingFinishedKey
|
|
14
|
+
{
|
|
15
|
+
return YES;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
- (BOOL)shouldShowAtLaunch
|
|
19
|
+
{
|
|
20
|
+
return NO;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@end
|
|
24
|
+
|
|
25
|
+
int main(int argc, char * argv[]) {
|
|
26
|
+
@autoreleasepool {
|
|
27
|
+
[DevMenuTestInterceptorManager setTestInterceptor:[DevMenuDetoxTestInterceptor new]];
|
|
28
|
+
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
package/tsconfig.json
CHANGED
package/.prettierrc
DELETED
package/build/Platform.ds.d.ts
DELETED