detox 21.0.0-rc.1 → 21.0.0-rc.10
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintignore +3 -0
- package/.eslintrc.js +1 -40
- package/Detox-android/com/wix/detox/{21.0.0-rc.1/detox-21.0.0-rc.1-javadoc.jar → 21.0.0-rc.10/detox-21.0.0-rc.10-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{21.0.0-rc.1/detox-21.0.0-rc.1-sources.jar → 21.0.0-rc.10/detox-21.0.0-rc.10-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.aar +0 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{21.0.0-rc.1/detox-21.0.0-rc.1.pom → 21.0.0-rc.10/detox-21.0.0-rc.10.pom} +1 -7
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.pom.sha512 +1 -0
- package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
- package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
- package/Detox-ios-framework.tbz +0 -0
- package/Detox-ios-src.tbz +0 -0
- package/Detox-ios-xcuitest.tbz +0 -0
- package/android/build.gradle +20 -10
- package/android/detox/build.gradle +24 -12
- package/android/detox/src/full/java/com/wix/detox/espresso/DetoxAssertion.java +44 -25
- package/android/detox/src/full/java/com/wix/detox/espresso/DetoxMatcher.java +12 -12
- package/android/detox/src/full/java/com/wix/detox/espresso/EspressoDetox.java +6 -7
- package/android/detox/src/full/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +2 -2
- package/android/detox/src/full/java/com/wix/detox/espresso/action/GetAttributesAction.kt +34 -35
- package/android/detox/src/full/java/com/wix/detox/espresso/common/MaterialSliderHelper.kt +21 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/common/{SliderHelper.kt → ReactSliderHelper.kt} +7 -6
- package/android/detox/src/full/java/com/wix/detox/espresso/matcher/RegexMatcher.kt +56 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/matcher/ViewMatchers.kt +18 -6
- package/android/detox/src/full/java/com/wix/detox/espresso/performer/MultipleViewsActionPerformer.kt +43 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/performer/SingleViewActionPerformer.kt +19 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/performer/ViewActionPerformer.kt +24 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/web/WebElement.java +4 -4
- package/android/detox/src/full/java/com/wix/invoke/types/Invocation.java +7 -6
- package/android/detox/src/main/java/com/wix/detox/espresso/MultipleViewsAction.kt +4 -0
- package/android/detox/src/main/java/com/wix/detox/espresso/UiControllerSpy.kt +0 -1
- package/android/detox/src/main/java/com/wix/detox/espresso/ViewActionWithResult.kt +2 -1
- package/android/detox/src/main/java/com/wix/detox/espresso/action/common/MotionEvents.kt +60 -4
- package/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt +6 -5
- package/android/detox/src/testFull/java/com/wix/detox/espresso/common/MaterialSliderHelperTest.kt +33 -0
- package/android/detox/src/testFull/java/com/wix/detox/espresso/common/{SliderHelperTest.kt → ReactSliderHelperTest.kt} +3 -3
- package/android/detox/src/testFull/java/com/wix/detox/espresso/matcher/RegexMatcherTest.kt +52 -0
- package/android/detox/src/testFull/java/com/wix/detox/espresso/performer/ViewActionPerformerSpec.kt +37 -0
- package/android/detox/src/testFull/java/com/wix/invoke/JsonParserTest.java +23 -7
- package/android/detox/src/testFull/resources/targetInvocationEspressoWebDetoxScript.json +47 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/rninfo.gradle +25 -0
- package/android/settings.gradle +2 -1
- package/detox.d.ts +1840 -0
- package/globals.d.ts +23 -0
- package/index.d.ts +2 -1789
- package/internals.d.ts +11 -1
- package/jest.config.js +108 -0
- package/local-cli/reset-lock-file.js +5 -9
- package/local-cli/startCommand/AppStartCommand.js +4 -1
- package/local-cli/testCommand/TestRunnerCommand.js +26 -3
- package/local-cli/utils/interruptListeners.js +15 -0
- package/package.json +15 -108
- package/runners/jest/reporter.js +21 -1
- package/runners/jest/reporters/DetoxIPCReporter.js +34 -0
- package/runners/jest/reporters/DetoxReporterDispatcher.js +144 -0
- package/runners/jest/reporters/DetoxSummaryReporter.js +16 -0
- package/runners/jest/reporters/DetoxVerboseReporter.js +16 -0
- package/runners/jest/reporters/index.js +6 -0
- package/runners/jest/testEnvironment/index.js +11 -0
- package/src/DetoxWorker.js +5 -11
- package/src/android/core/NativeElement.js +26 -29
- package/src/android/core/WebElement.js +24 -6
- package/src/android/espressoapi/DetoxAssertion.js +16 -14
- package/src/android/espressoapi/DetoxMatcher.js +24 -8
- package/src/android/espressoapi/EspressoDetox.js +9 -2
- package/src/android/espressoapi/web/WebElement.js +1 -4
- package/src/android/interactions/native.js +2 -3
- package/src/android/matchers/index.js +4 -0
- package/src/android/matchers/native.js +9 -4
- package/src/android/matchers/web.js +26 -1
- package/src/artifacts/providers/index.js +3 -3
- package/src/artifacts/screenshot/SimulatorScreenshotPlugin.js +0 -17
- package/src/configuration/composeLoggerConfig.js +1 -0
- package/src/configuration/composeRunnerConfig.js +3 -1
- package/src/devices/allocation/DeviceAllocator.js +66 -20
- package/src/devices/allocation/DeviceList.js +44 -0
- package/src/devices/allocation/DeviceRegistry.js +189 -0
- package/src/devices/allocation/drivers/AllocationDriverBase.d.ts +15 -0
- package/src/devices/{common/drivers/android/tools → allocation/drivers/android}/FreeDeviceFinder.js +11 -10
- package/src/devices/allocation/drivers/android/attached/AttachedAndroidAllocDriver.js +22 -17
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +97 -38
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +32 -45
- package/src/devices/allocation/drivers/android/emulator/FreeEmulatorFinder.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/FreePortFinder.js +37 -0
- package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +3 -3
- package/src/devices/allocation/drivers/android/genycloud/GenyAllocDriver.js +104 -32
- package/src/devices/allocation/drivers/android/genycloud/GenyInstanceLauncher.js +40 -31
- package/src/devices/allocation/drivers/android/genycloud/GenyRegistry.js +121 -0
- package/src/devices/allocation/drivers/android/genycloud/services/GenyInstanceLifecycleService.js +24 -0
- package/src/devices/{common → allocation}/drivers/android/genycloud/services/GenyRecipesService.js +1 -1
- package/src/devices/allocation/drivers/android/genycloud/services/dto/GenyInstance.js +83 -0
- package/src/devices/allocation/drivers/android/genycloud/services/dto/GenyRecipe.js +25 -0
- package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +95 -54
- package/src/devices/allocation/drivers/ios/SimulatorQuery.js +24 -0
- package/src/devices/allocation/factories/android.js +29 -35
- package/src/devices/allocation/factories/ios.js +6 -7
- package/src/devices/common/drivers/DeviceCookie.d.ts +12 -0
- package/src/devices/common/drivers/android/cookies.d.ts +11 -0
- package/src/devices/common/drivers/android/emulator/exec/EmulatorExec.js +17 -5
- package/src/devices/common/drivers/android/exec/ADB.js +1 -0
- package/src/devices/common/drivers/android/tools/instrumentationArgs.js +7 -1
- package/src/devices/common/drivers/ios/cookies.d.ts +9 -0
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +3 -1
- package/src/devices/cookies/index.js +0 -6
- package/src/devices/runtime/drivers/android/genycloud/GenyCloudDriver.js +7 -6
- package/src/devices/runtime/drivers/ios/SimulatorDriver.js +5 -4
- package/src/devices/runtime/drivers/ios/XCUITestUtils.js +21 -11
- package/src/devices/runtime/factories/android.js +3 -11
- package/src/devices/runtime/factories/ios.js +3 -4
- package/src/{servicelocator → devices/servicelocator}/android/emulatorServiceLocator.js +1 -1
- package/src/devices/servicelocator/android/genycloudServiceLocator.js +17 -0
- package/src/devices/servicelocator/android/index.js +23 -0
- package/src/{validation → devices/validation}/EnvironmentValidatorBase.js +1 -0
- package/src/{validation → devices/validation}/android/GenycloudEnvValidator.js +2 -2
- package/src/{validation → devices/validation}/factories/index.js +1 -1
- package/src/{validation → devices/validation}/ios/IosSimulatorEnvValidator.js +2 -2
- package/src/environmentFactory.js +1 -11
- package/src/invoke.js +0 -2
- package/src/ios/expectTwo.js +28 -11
- package/src/ios/web.js +302 -0
- package/src/ipc/IPCClient.js +22 -1
- package/src/ipc/IPCServer.js +42 -1
- package/src/ipc/SessionState.js +1 -0
- package/src/logger/DetoxLogger.js +2 -2
- package/src/realms/DetoxContext.js +8 -0
- package/src/realms/DetoxInternalsFacade.js +1 -0
- package/src/realms/DetoxPrimaryContext.js +49 -44
- package/src/realms/DetoxSecondaryContext.js +27 -0
- package/src/realms/symbols.js +6 -0
- package/src/utils/PIDService.js +27 -0
- package/src/utils/assertIsFunction.js +35 -0
- package/src/utils/environment.js +8 -15
- package/src/utils/errorUtils.js +3 -3
- package/src/utils/invocationTraceDescriptions.js +16 -0
- package/src/utils/isArrowFunction.js +24 -0
- package/src/utils/isRegExp.js +7 -0
- package/tsconfig.json +8 -3
- package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1.aar +0 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.1/detox-21.0.0-rc.1.pom.sha512 +0 -1
- package/runners/jest/reporters/DetoxReporter.js +0 -36
- package/src/devices/DeviceRegistry.js +0 -176
- package/src/devices/allocation/drivers/AllocationDriverBase.js +0 -30
- package/src/devices/allocation/drivers/android/attached/AttachedAndroidLauncher.js +0 -13
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +0 -72
- package/src/devices/allocation/drivers/android/genycloud/GenyDeviceRegistryFactory.js +0 -16
- package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +0 -65
- package/src/devices/allocation/drivers/ios/SimulatorLauncher.js +0 -21
- package/src/devices/common/drivers/DeviceAllocationHelper.js +0 -20
- package/src/devices/common/drivers/DeviceLauncher.js +0 -19
- package/src/devices/common/drivers/android/genycloud/services/GenyInstanceLifecycleService.js +0 -25
- package/src/devices/common/drivers/android/genycloud/services/GenyInstanceLookupService.js +0 -38
- package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +0 -14
- package/src/devices/common/drivers/android/genycloud/services/dto/GenyInstance.js +0 -66
- package/src/devices/common/drivers/android/genycloud/services/dto/GenyRecipe.js +0 -13
- package/src/devices/cookies/AndroidDeviceCookie.js +0 -13
- package/src/devices/cookies/AndroidEmulatorCookie.js +0 -6
- package/src/devices/cookies/AttachedAndroidDeviceCookie.js +0 -12
- package/src/devices/cookies/DeviceCookie.js +0 -4
- package/src/devices/cookies/GenycloudEmulatorCookie.js +0 -20
- package/src/devices/cookies/IosCookie.js +0 -6
- package/src/devices/cookies/IosSimulatorCookie.js +0 -10
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +0 -71
- package/src/devices/lifecycle/factories/GenyGlobalLifecycleHandlerFactory.js +0 -18
- package/src/invoke/EarlGrey.js +0 -8
- package/src/servicelocator/android/genycloudServiceLocator.js +0 -21
- package/src/servicelocator/android/index.js +0 -25
- package/src/servicelocator/ios.js +0 -7
- /package/src/devices/{common → allocation}/drivers/android/genycloud/exec/GenyCloudExec.js +0 -0
- /package/src/devices/{common → allocation}/drivers/android/genycloud/services/GenyAuthService.js +0 -0
package/src/realms/symbols.js
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
* readonly getStatus: unique symbol;
|
6
6
|
* readonly init: unique symbol;
|
7
7
|
* readonly installWorker: unique symbol;
|
8
|
+
* readonly allocateDevice: unique symbol;
|
9
|
+
* readonly deallocateDevice: unique symbol;
|
8
10
|
* readonly logger: unique symbol;
|
9
11
|
* readonly onHookFailure: unique symbol;
|
10
12
|
* readonly onRunDescribeFinish: unique symbol;
|
@@ -12,6 +14,7 @@
|
|
12
14
|
* readonly onTestDone: unique symbol;
|
13
15
|
* readonly onTestFnFailure: unique symbol;
|
14
16
|
* readonly onTestStart: unique symbol;
|
17
|
+
* readonly conductEarlyTeardown: unique symbol;
|
15
18
|
* readonly reportTestResults: unique symbol;
|
16
19
|
* readonly resolveConfig: unique symbol;
|
17
20
|
* readonly session: unique symbol;
|
@@ -32,6 +35,9 @@ module.exports = {
|
|
32
35
|
|
33
36
|
//#region IPC
|
34
37
|
reportTestResults: Symbol('reportTestResults'),
|
38
|
+
conductEarlyTeardown: Symbol('conductEarlyTeardown'),
|
39
|
+
allocateDevice: Symbol('allocateDevice'),
|
40
|
+
deallocateDevice: Symbol('deallocateDevice'),
|
35
41
|
//#endregion
|
36
42
|
|
37
43
|
//#region Main
|
@@ -0,0 +1,27 @@
|
|
1
|
+
const { pid } = require('process');
|
2
|
+
|
3
|
+
class PIDService {
|
4
|
+
getPid() {
|
5
|
+
return pid;
|
6
|
+
}
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Checks if the other process id is running in the current operating system
|
10
|
+
* @param {number} otherPID
|
11
|
+
* @returns {boolean}
|
12
|
+
*/
|
13
|
+
isAlive(otherPID) {
|
14
|
+
try {
|
15
|
+
process.kill(otherPID, 0);
|
16
|
+
return true;
|
17
|
+
} catch (ex) {
|
18
|
+
if (ex.code === 'ESRCH') {
|
19
|
+
return false;
|
20
|
+
}
|
21
|
+
throw ex;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
}
|
26
|
+
|
27
|
+
module.exports = PIDService;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
const isArrowFunction = require('./isArrowFunction');
|
2
|
+
|
3
|
+
const EXAMPLE = `Here are some examples of valid function strings:
|
4
|
+
|
5
|
+
1. function(el) { el.click(); }
|
6
|
+
2. el => el.click()
|
7
|
+
3. (el) => el.click()
|
8
|
+
`;
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Dynamically evaluates a string as a function and throws an error if it's not a function
|
12
|
+
* @param {string} str serialized function like 'function() { return 42; }'
|
13
|
+
*/
|
14
|
+
function assertIsFunction(str) {
|
15
|
+
let isFunction;
|
16
|
+
|
17
|
+
try {
|
18
|
+
isFunction = isFunctionDeclaration(str) && Function(`return typeof (${str})`)() === 'function';
|
19
|
+
} catch (e) {
|
20
|
+
isFunction = false;
|
21
|
+
}
|
22
|
+
|
23
|
+
if (!isFunction) {
|
24
|
+
throw new TypeError(`Expected a valid function string, but got: ${str}\n\n${EXAMPLE}`);
|
25
|
+
}
|
26
|
+
|
27
|
+
return str;
|
28
|
+
}
|
29
|
+
|
30
|
+
function isFunctionDeclaration(rawStr) {
|
31
|
+
const str = rawStr.trimStart();
|
32
|
+
return str.startsWith('async') || str.startsWith('function') || isArrowFunction(str);
|
33
|
+
}
|
34
|
+
|
35
|
+
module.exports = assertIsFunction;
|
package/src/utils/environment.js
CHANGED
@@ -19,9 +19,8 @@ function which(executable, path) {
|
|
19
19
|
const DETOX_LIBRARY_ROOT_PATH = path.join(appdatapath.appDataPath(), 'Detox');
|
20
20
|
const MISSING_SDK_ERROR = `$ANDROID_SDK_ROOT is not defined, set the path to the SDK installation directory into $ANDROID_SDK_ROOT,
|
21
21
|
Go to https://developer.android.com/studio/command-line/variables.html for more details`;
|
22
|
-
const
|
23
|
-
const
|
24
|
-
const GENYCLOUD_GLOBAL_CLEANUP_FILE_PATH = path.join(DETOX_LIBRARY_ROOT_PATH, 'genycloud-cleanup.lock');
|
22
|
+
const DETOX_LOCK_FILE_PATH = path.join(DETOX_LIBRARY_ROOT_PATH, 'global-context.json');
|
23
|
+
const DEVICE_REGISTRY_PATH = path.join(DETOX_LIBRARY_ROOT_PATH, 'device.registry.json');
|
25
24
|
const LAST_FAILED_TESTS_PATH = path.join(DETOX_LIBRARY_ROOT_PATH, 'last-failed.txt');
|
26
25
|
|
27
26
|
function getAndroidSDKPath() {
|
@@ -218,17 +217,12 @@ function getDetoxLibraryRootPath() {
|
|
218
217
|
return DETOX_LIBRARY_ROOT_PATH;
|
219
218
|
}
|
220
219
|
|
221
|
-
function
|
222
|
-
return
|
220
|
+
function getDetoxLockFilePath() {
|
221
|
+
return DETOX_LOCK_FILE_PATH;
|
223
222
|
}
|
224
223
|
|
225
|
-
|
226
|
-
|
227
|
-
return DEVICE_LOCK_FILE_PATH_ANDROID;
|
228
|
-
}
|
229
|
-
|
230
|
-
function getGenyCloudGlobalCleanupFilePath() {
|
231
|
-
return GENYCLOUD_GLOBAL_CLEANUP_FILE_PATH;
|
224
|
+
function getDeviceRegistryPath() {
|
225
|
+
return DEVICE_REGISTRY_PATH;
|
232
226
|
}
|
233
227
|
|
234
228
|
function getLastFailedTestsPath() {
|
@@ -253,9 +247,8 @@ module.exports = {
|
|
253
247
|
getAndroidSDKPath,
|
254
248
|
getAndroidEmulatorPath,
|
255
249
|
getDetoxLibraryRootPath,
|
256
|
-
|
257
|
-
|
258
|
-
getGenyCloudGlobalCleanupFilePath,
|
250
|
+
getDetoxLockFilePath,
|
251
|
+
getDeviceRegistryPath,
|
259
252
|
getLastFailedTestsPath,
|
260
253
|
getHomeDir,
|
261
254
|
};
|
package/src/utils/errorUtils.js
CHANGED
@@ -40,15 +40,15 @@ function asError(error) {
|
|
40
40
|
return isError(error) ? error : new Error(error);
|
41
41
|
}
|
42
42
|
|
43
|
-
function serializeObjectWithError(obj, errorKey) {
|
44
|
-
if (obj[errorKey]) {
|
43
|
+
function serializeObjectWithError(obj, errorKey = 'error') {
|
44
|
+
if (obj[errorKey] instanceof Error) {
|
45
45
|
return { ...obj, [errorKey]: serializeError(obj[errorKey]) };
|
46
46
|
}
|
47
47
|
|
48
48
|
return obj;
|
49
49
|
}
|
50
50
|
|
51
|
-
function deserializeObjectWithError(obj, errorKey) {
|
51
|
+
function deserializeObjectWithError(obj, errorKey = 'error') {
|
52
52
|
if (typeof obj[errorKey] === 'object' && !(obj[errorKey] instanceof Error)) {
|
53
53
|
return { ...obj, [errorKey]: deserializeError(obj[errorKey]) };
|
54
54
|
}
|
@@ -26,6 +26,22 @@ module.exports = {
|
|
26
26
|
tapReturnKey: () => 'tap on return key',
|
27
27
|
typeText: (value) => `type input text: "${value}"`,
|
28
28
|
},
|
29
|
+
webViewActionDescription: {
|
30
|
+
tap: (value) => `tap${value !== undefined ? ` at ${JSON.stringify(value)}` : ''}`,
|
31
|
+
typeText: (value, isContentEditable) => `type input text: "${value}"${isContentEditable ? ' in content editable' : ''}`,
|
32
|
+
replaceText: (value) => `replace input text: "${value}"`,
|
33
|
+
clearText: () => 'clear input text',
|
34
|
+
selectAllText: () => 'select all input text',
|
35
|
+
getText: () => 'get input text',
|
36
|
+
scrollToView: () => 'scroll to view',
|
37
|
+
focus: () => 'focus',
|
38
|
+
moveCursorToEnd: () => 'move cursor to end',
|
39
|
+
runScript: (script) => `run script: "${script}"`,
|
40
|
+
runScriptWithArgs: (script, ...args) => `run script: "${script}" with args: "${args}"`,
|
41
|
+
getCurrentUrl: () => 'get current url',
|
42
|
+
getTitle: () => 'get title',
|
43
|
+
full: (actionDescription) => `perform web view action: ${actionDescription}`
|
44
|
+
},
|
29
45
|
expectDescription: {
|
30
46
|
waitFor: (actionDescription) => `wait for expectation while ${actionDescription}`,
|
31
47
|
waitForWithTimeout: (expectDescription, timeout) => `${expectDescription} with timeout (${timeout} ms)`,
|
@@ -0,0 +1,24 @@
|
|
1
|
+
function isArrowFunction(code) {
|
2
|
+
if (!code.includes('=>')) {
|
3
|
+
return false;
|
4
|
+
}
|
5
|
+
|
6
|
+
const syncCode = removeAsync(code.trimStart());
|
7
|
+
return syncCode.startsWith('(') || isSimpleArrowFunction(code);
|
8
|
+
}
|
9
|
+
|
10
|
+
function removeAsync(code) {
|
11
|
+
return code.startsWith('async') ? code.slice(5).trimStart() : code;
|
12
|
+
}
|
13
|
+
|
14
|
+
function isSimpleArrowFunction(code) {
|
15
|
+
const [signature] = code.split('=>', 1);
|
16
|
+
|
17
|
+
return isAlphanumericId(removeAsync(signature.trim()));
|
18
|
+
}
|
19
|
+
|
20
|
+
function isAlphanumericId(code) {
|
21
|
+
return /^[a-zA-Z0-9]+$/.test(code);
|
22
|
+
}
|
23
|
+
|
24
|
+
module.exports = isArrowFunction;
|
package/tsconfig.json
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"compilerOptions": {
|
3
3
|
"module": "commonjs",
|
4
|
-
"lib": ["
|
5
|
-
"target": "
|
4
|
+
"lib": ["es2022"],
|
5
|
+
"target": "ES2022",
|
6
6
|
"allowJs": true,
|
7
7
|
"checkJs": true,
|
8
|
-
"moduleResolution": "
|
8
|
+
"moduleResolution": "node16",
|
9
9
|
"resolveJsonModule": true,
|
10
10
|
"esModuleInterop": true,
|
11
11
|
"noEmit": true,
|
@@ -15,11 +15,16 @@
|
|
15
15
|
},
|
16
16
|
"rootDir": ".",
|
17
17
|
"include": [
|
18
|
+
"detox.d.ts",
|
19
|
+
"globals.d.ts",
|
20
|
+
"index.d.ts",
|
18
21
|
"**/*.js",
|
19
22
|
"**/*.ts"
|
20
23
|
],
|
21
24
|
"exclude": [
|
22
25
|
"android",
|
26
|
+
"allure-report",
|
27
|
+
"allure-results",
|
23
28
|
"coverage",
|
24
29
|
"ios",
|
25
30
|
"test"
|
@@ -1 +0,0 @@
|
|
1
|
-
676f5623f18f5aea064a7f6904246400
|
@@ -1 +0,0 @@
|
|
1
|
-
d32d1da12814abb3d8e01679ad4c8d1990eae026
|
@@ -1 +0,0 @@
|
|
1
|
-
98265e2b8bebc95442122095e0bb7b2384a5533c41ca06d6f657155c9486f541
|
@@ -1 +0,0 @@
|
|
1
|
-
d6ef87187436aab9cb1c8a9e5e81e28a00cf3cee24676af52aeecdeb735ddf7ca4a5106a3d426eac93c21ed6296d94e7d4fb713916c327cd103b78274e1fea8b
|
@@ -1 +0,0 @@
|
|
1
|
-
184c4a09715cd95bb7d7b24d9c8cf4fe
|
@@ -1 +0,0 @@
|
|
1
|
-
f159e51ccbe1e841883214ff1b33c918621f1313
|
@@ -1 +0,0 @@
|
|
1
|
-
e603b2aa787dfed82694c592c931932d22a0ed57f80f49cd29ea915205ce32dd
|
@@ -1 +0,0 @@
|
|
1
|
-
a8ab95fb0242cd1b171eb6110dcb074f37f1624ad125fc9e5636ef49bce8f13267ee42554bb3ca7b733e9d9bb18121d5474211a8f7851e0aee6ffadf61ede2ac
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
e89d3204dcda439e4deb0df61603394a
|
@@ -1 +0,0 @@
|
|
1
|
-
eda5c226e954731b3dbd16becbab72f66888d5ce
|
@@ -1 +0,0 @@
|
|
1
|
-
4da9ab41881efc27c7268bff2bfbb7092d9dbdf6de8f43787b4df649f0291bff
|
@@ -1 +0,0 @@
|
|
1
|
-
c63bf901eb0327ca3791b419f99dd67060a9b48a816da5c71e7e660e60fed607347ef8f76710969e9497054cc4f99add8db19f47b7e780ee3e6413df6d75e195
|
@@ -1 +0,0 @@
|
|
1
|
-
56630a38d1cc52c7f6824256df9ed847
|
@@ -1 +0,0 @@
|
|
1
|
-
dfe72c2c93cd64a1a440678e5851f4cac4dc6cd6
|
@@ -1 +0,0 @@
|
|
1
|
-
27fc8d10e708002a4f6c0b355e887e471374b0ea43e9c98fd7a79fef1ca19404
|
@@ -1 +0,0 @@
|
|
1
|
-
9141aad6501bde06c8bcf86430bf2506b147ebb982a1400e7e6ce3b224b33150a106293b055fda6ab0963912798fe914600664003457b3cbe34f0ef233dfe265
|
@@ -1,36 +0,0 @@
|
|
1
|
-
const resolveFrom = require('resolve-from');
|
2
|
-
/** @type {typeof import('@jest/reporters').VerboseReporter} */
|
3
|
-
const JestVerboseReporter = require(resolveFrom(process.cwd(), '@jest/reporters')).VerboseReporter;
|
4
|
-
|
5
|
-
const { config, reportTestResults } = require('../../../internals');
|
6
|
-
|
7
|
-
class DetoxReporter extends JestVerboseReporter {
|
8
|
-
/**
|
9
|
-
* @param {import('@jest/test-result').AggregatedResult} results
|
10
|
-
*/
|
11
|
-
// @ts-ignore
|
12
|
-
async onRunComplete(_contexts, results) {
|
13
|
-
// @ts-ignore
|
14
|
-
await super.onRunComplete(_contexts, results);
|
15
|
-
|
16
|
-
await reportTestResults(results.testResults.map(r => ({
|
17
|
-
success: !r.failureMessage,
|
18
|
-
testFilePath: r.testFilePath,
|
19
|
-
testExecError: r.testExecError,
|
20
|
-
isPermanentFailure: this._isPermanentFailure(r),
|
21
|
-
})));
|
22
|
-
}
|
23
|
-
|
24
|
-
/**
|
25
|
-
* @param {import('@jest/test-result').TestResult} testResult
|
26
|
-
*/
|
27
|
-
_isPermanentFailure(testResult) {
|
28
|
-
if (config.testRunner.jest.retryAfterCircusRetries) {
|
29
|
-
return false;
|
30
|
-
}
|
31
|
-
|
32
|
-
return testResult.testResults.some(r => r.status === 'failed' && r.invocations > 1);
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
module.exports = DetoxReporter;
|
@@ -1,176 +0,0 @@
|
|
1
|
-
// @ts-nocheck
|
2
|
-
const fs = require('fs-extra');
|
3
|
-
const _ = require('lodash');
|
4
|
-
|
5
|
-
const ExclusiveLockfile = require('../utils/ExclusiveLockfile');
|
6
|
-
const environment = require('../utils/environment');
|
7
|
-
const safeAsync = require('../utils/safeAsync');
|
8
|
-
|
9
|
-
const readOptions = {
|
10
|
-
encoding: 'utf8',
|
11
|
-
};
|
12
|
-
|
13
|
-
const FIELD_NAME_ID = 'id';
|
14
|
-
const FIELD_NAME_DATA = 'data';
|
15
|
-
|
16
|
-
class DevicesList {
|
17
|
-
constructor(devices) {
|
18
|
-
this._devices = Object.freeze(devices);
|
19
|
-
}
|
20
|
-
|
21
|
-
/**
|
22
|
-
* @returns {{id: string, data: *?}[]}
|
23
|
-
*/
|
24
|
-
get rawDevices() {
|
25
|
-
return this._devices;
|
26
|
-
}
|
27
|
-
|
28
|
-
/**
|
29
|
-
* @param {string} deviceId
|
30
|
-
* @returns {boolean}
|
31
|
-
*/
|
32
|
-
includes(deviceId) {
|
33
|
-
return DevicesList._includes(deviceId, this._devices);
|
34
|
-
}
|
35
|
-
|
36
|
-
static _includes(deviceId, devices) {
|
37
|
-
return _.some(devices, [FIELD_NAME_ID, deviceId]);
|
38
|
-
}
|
39
|
-
}
|
40
|
-
|
41
|
-
class DeviceRegistry {
|
42
|
-
constructor({ lockfilePath }) {
|
43
|
-
/***
|
44
|
-
* @private
|
45
|
-
* @type {string}
|
46
|
-
*/
|
47
|
-
this._lockfilePath = lockfilePath;
|
48
|
-
|
49
|
-
/***
|
50
|
-
* @protected
|
51
|
-
* @type {ExclusiveLockfile}
|
52
|
-
*/
|
53
|
-
this._lockfile = new ExclusiveLockfile(lockfilePath, {
|
54
|
-
getInitialState: this._getInitialLockFileState.bind(this),
|
55
|
-
readOptions,
|
56
|
-
});
|
57
|
-
}
|
58
|
-
|
59
|
-
async reset() {
|
60
|
-
await this._lockfile.exclusively(() => {
|
61
|
-
const empty = this._getInitialLockFileState();
|
62
|
-
this._lockfile.write(empty);
|
63
|
-
});
|
64
|
-
}
|
65
|
-
|
66
|
-
/***
|
67
|
-
* @param {string|Function} getDeviceId
|
68
|
-
* @param {*?} data
|
69
|
-
* @returns {Promise<string>}
|
70
|
-
*/
|
71
|
-
async allocateDevice(getDeviceId, data) {
|
72
|
-
return this._lockfile.exclusively(async () => {
|
73
|
-
const deviceId = await safeAsync(getDeviceId);
|
74
|
-
this._registerDevice(deviceId, data);
|
75
|
-
return deviceId;
|
76
|
-
});
|
77
|
-
}
|
78
|
-
|
79
|
-
/***
|
80
|
-
* @param {string|Function} getDeviceId
|
81
|
-
* @returns {Promise<void>}
|
82
|
-
*/
|
83
|
-
async disposeDevice(getDeviceId) {
|
84
|
-
await this._lockfile.exclusively(async () => {
|
85
|
-
const deviceId = await safeAsync(getDeviceId);
|
86
|
-
if (deviceId) {
|
87
|
-
this._unregisterDevice(deviceId);
|
88
|
-
}
|
89
|
-
});
|
90
|
-
}
|
91
|
-
|
92
|
-
/***
|
93
|
-
* @param {string} deviceId
|
94
|
-
* @returns {boolean}
|
95
|
-
*/
|
96
|
-
includes(deviceId) {
|
97
|
-
const devices = this._lockfile.read();
|
98
|
-
return DevicesList._includes(deviceId, devices);
|
99
|
-
}
|
100
|
-
|
101
|
-
/***
|
102
|
-
* @returns {DevicesList}
|
103
|
-
*/
|
104
|
-
getRegisteredDevices() {
|
105
|
-
const devices = this._lockfile.read();
|
106
|
-
return new DevicesList(devices);
|
107
|
-
}
|
108
|
-
|
109
|
-
/***
|
110
|
-
* @returns {DevicesList}
|
111
|
-
*/
|
112
|
-
async readRegisteredDevices() {
|
113
|
-
let result = null;
|
114
|
-
await this._lockfile.exclusively(() => {
|
115
|
-
result = this.getRegisteredDevices();
|
116
|
-
});
|
117
|
-
return result;
|
118
|
-
}
|
119
|
-
|
120
|
-
/***
|
121
|
-
* @returns {DevicesList}
|
122
|
-
*/
|
123
|
-
readRegisteredDevicesUNSAFE() {
|
124
|
-
const contents = fs.readFileSync(this._lockfilePath, readOptions);
|
125
|
-
const devices = JSON.parse(contents);
|
126
|
-
return new DevicesList(devices);
|
127
|
-
}
|
128
|
-
|
129
|
-
/***
|
130
|
-
* @private
|
131
|
-
*/
|
132
|
-
_getInitialLockFileState() {
|
133
|
-
return [];
|
134
|
-
}
|
135
|
-
|
136
|
-
/**
|
137
|
-
* @private
|
138
|
-
*/
|
139
|
-
_registerDevice(deviceId, data) {
|
140
|
-
const state = this._lockfile.read();
|
141
|
-
let newState = _.reject(state, [FIELD_NAME_ID, deviceId]);
|
142
|
-
|
143
|
-
const device = {};
|
144
|
-
device[FIELD_NAME_ID] = deviceId;
|
145
|
-
|
146
|
-
if (data) {
|
147
|
-
device[FIELD_NAME_DATA] = data;
|
148
|
-
}
|
149
|
-
|
150
|
-
newState = _.concat(newState, device);
|
151
|
-
this._lockfile.write(newState);
|
152
|
-
}
|
153
|
-
|
154
|
-
/**
|
155
|
-
* @private
|
156
|
-
*/
|
157
|
-
_unregisterDevice(deviceId) {
|
158
|
-
const state = this._lockfile.read();
|
159
|
-
const newState = _.reject(state, [FIELD_NAME_ID, deviceId]);
|
160
|
-
this._lockfile.write(newState);
|
161
|
-
}
|
162
|
-
|
163
|
-
static forIOS() {
|
164
|
-
return new DeviceRegistry({
|
165
|
-
lockfilePath: environment.getDeviceLockFilePathIOS(),
|
166
|
-
});
|
167
|
-
}
|
168
|
-
|
169
|
-
static forAndroid() {
|
170
|
-
return new DeviceRegistry({
|
171
|
-
lockfilePath: environment.getDeviceLockFilePathAndroid(),
|
172
|
-
});
|
173
|
-
}
|
174
|
-
}
|
175
|
-
|
176
|
-
module.exports = DeviceRegistry;
|
@@ -1,30 +0,0 @@
|
|
1
|
-
/* eslint @typescript-eslint/no-unused-vars: ["error", { "args": "none" }] */
|
2
|
-
// @ts-nocheck
|
3
|
-
|
4
|
-
/**
|
5
|
-
* @typedef DeallocOptions
|
6
|
-
* @property shutdown { Boolean }
|
7
|
-
*/
|
8
|
-
|
9
|
-
class AllocationDriverBase {
|
10
|
-
/**
|
11
|
-
* @param deviceConfig { Object }
|
12
|
-
* @return {Promise<DeviceCookie>}
|
13
|
-
*/
|
14
|
-
async allocate(deviceConfig) {}
|
15
|
-
|
16
|
-
/**
|
17
|
-
* @param {DeviceCookie} deviceCookie
|
18
|
-
* @return {Promise<void>}
|
19
|
-
*/
|
20
|
-
async postAllocate(deviceCookie) {}
|
21
|
-
|
22
|
-
/**
|
23
|
-
* @param cookie { DeviceCookie }
|
24
|
-
* @param options { DeallocOptions }
|
25
|
-
* @return {Promise<void>}
|
26
|
-
*/
|
27
|
-
async free(cookie, options) {}
|
28
|
-
}
|
29
|
-
|
30
|
-
module.exports = AllocationDriverBase;
|
@@ -1,13 +0,0 @@
|
|
1
|
-
const DeviceLauncher = require('../../../../common/drivers/DeviceLauncher');
|
2
|
-
|
3
|
-
class AttachedAndroidLauncher extends DeviceLauncher {
|
4
|
-
constructor(eventEmitter) {
|
5
|
-
super(eventEmitter);
|
6
|
-
}
|
7
|
-
|
8
|
-
notifyLaunchCompleted(adbName) {
|
9
|
-
return super._notifyBootEvent(adbName, 'device', false);
|
10
|
-
}
|
11
|
-
}
|
12
|
-
|
13
|
-
module.exports = AttachedAndroidLauncher;
|
@@ -1,72 +0,0 @@
|
|
1
|
-
const logger = require('../../../../../utils/logger').child({ cat: 'device' });
|
2
|
-
const DeviceAllocationHelper = require('../../../../common/drivers/DeviceAllocationHelper');
|
3
|
-
|
4
|
-
const DetoxEmulatorsPortRange = {
|
5
|
-
min: 10000,
|
6
|
-
max: 20000
|
7
|
-
};
|
8
|
-
|
9
|
-
class AllocationResult {
|
10
|
-
constructor(adbName, placeholderPort) {
|
11
|
-
this.adbName = adbName;
|
12
|
-
this.placeholderPort = placeholderPort;
|
13
|
-
}
|
14
|
-
|
15
|
-
get isRunning() {
|
16
|
-
return !this.placeholderPort;
|
17
|
-
}
|
18
|
-
}
|
19
|
-
|
20
|
-
class EmulatorAllocationHelper extends DeviceAllocationHelper {
|
21
|
-
constructor(deviceRegistry, freeDeviceFinder, rand = Math.random) {
|
22
|
-
super(deviceRegistry, logger);
|
23
|
-
this._freeDeviceFinder = freeDeviceFinder;
|
24
|
-
this._rand = rand;
|
25
|
-
}
|
26
|
-
|
27
|
-
/**
|
28
|
-
* @param avdName
|
29
|
-
* @returns {Promise<AllocationResult>}
|
30
|
-
*/
|
31
|
-
async allocateDevice(avdName) {
|
32
|
-
this._logAllocationAttempt(avdName);
|
33
|
-
|
34
|
-
const result = await this._doSynchronizedAllocation(avdName);
|
35
|
-
this._logAllocationResult(avdName, result.adbName);
|
36
|
-
|
37
|
-
return result;
|
38
|
-
}
|
39
|
-
|
40
|
-
async deallocateDevice(adbName) {
|
41
|
-
await this._deviceRegistry.disposeDevice(adbName);
|
42
|
-
}
|
43
|
-
|
44
|
-
/**
|
45
|
-
* @returns {Promise<AllocationResult>}
|
46
|
-
* @private
|
47
|
-
*/
|
48
|
-
async _doSynchronizedAllocation(avdName) {
|
49
|
-
let placeholderPort = null;
|
50
|
-
let adbName = null;
|
51
|
-
|
52
|
-
await this._deviceRegistry.allocateDevice(async () => {
|
53
|
-
adbName = await this._freeDeviceFinder.findFreeDevice(avdName);
|
54
|
-
if (!adbName) {
|
55
|
-
placeholderPort = this._allocateEmulatorPlaceholderPort();
|
56
|
-
adbName = `emulator-${placeholderPort}`;
|
57
|
-
}
|
58
|
-
return adbName;
|
59
|
-
});
|
60
|
-
|
61
|
-
return new AllocationResult(adbName, placeholderPort);
|
62
|
-
}
|
63
|
-
|
64
|
-
_allocateEmulatorPlaceholderPort() {
|
65
|
-
const { min, max } = DetoxEmulatorsPortRange;
|
66
|
-
let port = this._rand() * (max - min) + min;
|
67
|
-
port = port & 0xFFFFFFFE; // Should always be even
|
68
|
-
return port;
|
69
|
-
}
|
70
|
-
}
|
71
|
-
|
72
|
-
module.exports = EmulatorAllocationHelper;
|
@@ -1,16 +0,0 @@
|
|
1
|
-
const environment = require('../../../../../utils/environment');
|
2
|
-
const DeviceRegistry = require('../../../../DeviceRegistry');
|
3
|
-
|
4
|
-
class GenyDeviceRegistryFactory {
|
5
|
-
forRuntime() {
|
6
|
-
return DeviceRegistry.forAndroid();
|
7
|
-
}
|
8
|
-
|
9
|
-
forGlobalShutdown() {
|
10
|
-
return new DeviceRegistry({
|
11
|
-
lockfilePath: environment.getGenyCloudGlobalCleanupFilePath(),
|
12
|
-
});
|
13
|
-
}
|
14
|
-
}
|
15
|
-
|
16
|
-
module.exports = new GenyDeviceRegistryFactory();
|