detox 21.0.0-rc.5 → 21.0.0-rc.7
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintignore +1 -0
- package/Detox-android/com/wix/detox/{21.0.0-rc.5/detox-21.0.0-rc.5-javadoc.jar → 21.0.0-rc.7/detox-21.0.0-rc.7-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{21.0.0-rc.5/detox-21.0.0-rc.5-sources.jar → 21.0.0-rc.7/detox-21.0.0-rc.7-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7.aar +0 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{21.0.0-rc.5/detox-21.0.0-rc.5.pom → 21.0.0-rc.7/detox-21.0.0-rc.7.pom} +1 -7
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7.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 +1 -1
- package/android/detox/build.gradle +13 -8
- package/android/detox/src/full/java/com/wix/detox/espresso/DetoxAssertion.java +44 -25
- 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} +6 -5
- package/android/detox/src/full/java/com/wix/detox/espresso/matcher/ViewMatchers.kt +2 -2
- 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/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/rninfo.gradle +3 -3
- package/detox.d.ts +1830 -0
- package/globals.d.ts +23 -0
- package/index.d.ts +2 -1823
- package/internals.d.ts +11 -1
- package/jest.config.js +108 -0
- package/local-cli/reset-lock-file.js +5 -9
- package/local-cli/testCommand/TestRunnerCommand.js +26 -3
- package/local-cli/utils/interruptListeners.js +15 -0
- package/package.json +2 -100
- 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/EspressoDetox.js +9 -2
- package/src/android/espressoapi/web/WebElement.js +1 -4
- package/src/android/interactions/native.js +2 -3
- 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 +18 -7
- 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/ios/web.js +21 -5
- 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 +48 -42
- 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/isArrowFunction.js +24 -0
- package/tsconfig.json +8 -3
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5.aar +0 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5.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/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/DetoxWorker.js
CHANGED
@@ -33,7 +33,6 @@ class DetoxWorker {
|
|
33
33
|
onError: this._onEmitError.bind(this),
|
34
34
|
});
|
35
35
|
|
36
|
-
|
37
36
|
/** @type {DetoxInternals.RuntimeConfig['apps']} */
|
38
37
|
this._appsConfig = null;
|
39
38
|
/** @type {DetoxInternals.RuntimeConfig['artifacts']} */
|
@@ -60,7 +59,6 @@ class DetoxWorker {
|
|
60
59
|
/** @type {Detox.WebFacade} */
|
61
60
|
this.web = null;
|
62
61
|
|
63
|
-
this._deviceAllocator = null;
|
64
62
|
this._deviceCookie = null;
|
65
63
|
|
66
64
|
this.trace = this._context.trace;
|
@@ -115,14 +113,13 @@ class DetoxWorker {
|
|
115
113
|
const {
|
116
114
|
// @ts-ignore
|
117
115
|
envValidatorFactory,
|
118
|
-
deviceAllocatorFactory,
|
119
116
|
// @ts-ignore
|
120
117
|
artifactsManagerFactory,
|
121
118
|
// @ts-ignore
|
122
119
|
matchersFactory,
|
123
120
|
// @ts-ignore
|
124
121
|
runtimeDeviceFactory,
|
125
|
-
} = environmentFactory.createFactories(
|
122
|
+
} = environmentFactory.createFactories(deviceConfig);
|
126
123
|
|
127
124
|
const envValidator = envValidatorFactory.createValidator();
|
128
125
|
yield envValidator.validate();
|
@@ -135,10 +132,7 @@ class DetoxWorker {
|
|
135
132
|
};
|
136
133
|
|
137
134
|
this._artifactsManager = artifactsManagerFactory.createArtifactsManager(this._artifactsConfig, commonDeps);
|
138
|
-
this.
|
139
|
-
this._deviceCookie = yield this._deviceAllocator.allocate(this._deviceConfig);
|
140
|
-
|
141
|
-
yield this._deviceAllocator.postAllocate(this._deviceCookie);
|
135
|
+
this._deviceCookie = yield this._context[symbols.allocateDevice]();
|
142
136
|
|
143
137
|
this.device = runtimeDeviceFactory.createRuntimeDevice(
|
144
138
|
this._deviceCookie,
|
@@ -157,6 +151,8 @@ class DetoxWorker {
|
|
157
151
|
});
|
158
152
|
Object.assign(this, matchers);
|
159
153
|
|
154
|
+
yield this._eventEmitter.emit('bootDevice', { deviceId: this.device.id });
|
155
|
+
|
160
156
|
if (behaviorConfig.init.exposeGlobals) {
|
161
157
|
const injectedGlobals = {
|
162
158
|
...matchers,
|
@@ -207,11 +203,9 @@ class DetoxWorker {
|
|
207
203
|
}
|
208
204
|
|
209
205
|
if (this._deviceCookie) {
|
210
|
-
|
211
|
-
await this._deviceAllocator.free(this._deviceCookie, { shutdown });
|
206
|
+
await this._context[symbols.deallocateDevice](this._deviceCookie);
|
212
207
|
}
|
213
208
|
|
214
|
-
this._deviceAllocator = null;
|
215
209
|
this._deviceCookie = null;
|
216
210
|
this.device = null;
|
217
211
|
}
|
@@ -15,39 +15,37 @@ class NativeElement {
|
|
15
15
|
constructor(invocationManager, emitter, matcher) {
|
16
16
|
this._invocationManager = invocationManager;
|
17
17
|
this._emitter = emitter;
|
18
|
-
this.
|
19
|
-
this._selectElementWithMatcher(this._originalMatcher);
|
18
|
+
this._matcher = matcher;
|
20
19
|
}
|
21
20
|
|
22
|
-
|
23
|
-
|
21
|
+
get _call() {
|
22
|
+
return invoke.call(invoke.Espresso, 'onView', this._matcher._call);
|
24
23
|
}
|
25
24
|
|
26
25
|
atIndex(index) {
|
27
26
|
if (typeof index !== 'number') throw new DetoxRuntimeError({ message: `Element atIndex argument must be a number, got ${typeof index}` });
|
28
|
-
const matcher = this.
|
29
|
-
this.
|
27
|
+
const matcher = this._matcher;
|
28
|
+
this._matcher._call = invoke.callDirectly(DetoxMatcherApi.matcherForAtIndex(index, matcher._call.value));
|
30
29
|
|
31
|
-
this._selectElementWithMatcher(this._originalMatcher);
|
32
30
|
return this;
|
33
31
|
}
|
34
32
|
|
35
33
|
async tap(value) {
|
36
34
|
const action = new actions.TapAction(value);
|
37
35
|
const traceDescription = actionDescription.tapAtPoint(value);
|
38
|
-
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
36
|
+
return await new ActionInteraction(this._invocationManager, this._matcher, action, traceDescription).execute();
|
39
37
|
}
|
40
38
|
|
41
39
|
async tapAtPoint(value) {
|
42
40
|
const action = new actions.TapAtPointAction(value);
|
43
41
|
const traceDescription = actionDescription.tapAtPoint(value);
|
44
|
-
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
42
|
+
return await new ActionInteraction(this._invocationManager, this._matcher, action, traceDescription).execute();
|
45
43
|
}
|
46
44
|
|
47
45
|
async longPress() {
|
48
46
|
const action = new actions.LongPressAction();
|
49
47
|
const traceDescription = actionDescription.longPress();
|
50
|
-
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
48
|
+
return await new ActionInteraction(this._invocationManager, this._matcher, action, traceDescription).execute();
|
51
49
|
}
|
52
50
|
|
53
51
|
async multiTap(times) {
|
@@ -56,61 +54,61 @@ class NativeElement {
|
|
56
54
|
|
57
55
|
const action = new actions.MultiClickAction(times);
|
58
56
|
const traceDescription = actionDescription.multiTap(times);
|
59
|
-
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
57
|
+
return await new ActionInteraction(this._invocationManager, this._matcher, action, traceDescription).execute();
|
60
58
|
}
|
61
59
|
|
62
60
|
async tapBackspaceKey() {
|
63
61
|
const action = new actions.PressKeyAction(67);
|
64
62
|
const traceDescription = actionDescription.tapBackspaceKey();
|
65
|
-
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
63
|
+
return await new ActionInteraction(this._invocationManager, this._matcher, action, traceDescription).execute();
|
66
64
|
}
|
67
65
|
|
68
66
|
async tapReturnKey() {
|
69
67
|
const action = new actions.TypeTextAction('\n');
|
70
68
|
const traceDescription = actionDescription.tapReturnKey();
|
71
|
-
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
69
|
+
return await new ActionInteraction(this._invocationManager, this._matcher, action, traceDescription).execute();
|
72
70
|
}
|
73
71
|
|
74
72
|
async typeText(value) {
|
75
73
|
const action = new actions.TypeTextAction(value);
|
76
74
|
const traceDescription = actionDescription.typeText(value);
|
77
|
-
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
75
|
+
return await new ActionInteraction(this._invocationManager, this._matcher, action, traceDescription).execute();
|
78
76
|
}
|
79
77
|
|
80
78
|
async replaceText(value) {
|
81
79
|
const action = new actions.ReplaceTextAction(value);
|
82
80
|
const traceDescription = actionDescription.replaceText(value);
|
83
|
-
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
81
|
+
return await new ActionInteraction(this._invocationManager, this._matcher, action, traceDescription).execute();
|
84
82
|
}
|
85
83
|
|
86
84
|
async clearText() {
|
87
85
|
const action = new actions.ClearTextAction();
|
88
86
|
const traceDescription = actionDescription.clearText();
|
89
|
-
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
87
|
+
return await new ActionInteraction(this._invocationManager, this._matcher, action, traceDescription).execute();
|
90
88
|
}
|
91
89
|
|
92
90
|
async scroll(amount, direction = 'down', startPositionX, startPositionY) {
|
93
91
|
const action = new actions.ScrollAmountAction(direction, amount, startPositionX, startPositionY);
|
94
92
|
const traceDescription = actionDescription.scroll(amount, direction, startPositionX, startPositionY);
|
95
|
-
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
93
|
+
return await new ActionInteraction(this._invocationManager, this._matcher, action, traceDescription).execute();
|
96
94
|
}
|
97
95
|
|
98
96
|
async scrollTo(edge) {
|
99
97
|
// override the user's element selection with an extended matcher that looks for UIScrollView children
|
100
|
-
this.
|
98
|
+
this._matcher = this._matcher._extendToDescendantScrollViews();
|
101
99
|
|
102
100
|
const action = new actions.ScrollEdgeAction(edge);
|
103
101
|
const traceDescription = actionDescription.scrollTo(edge);
|
104
|
-
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
102
|
+
return await new ActionInteraction(this._invocationManager, this._matcher, action, traceDescription).execute();
|
105
103
|
}
|
106
104
|
|
107
105
|
async scrollToIndex(index) {
|
108
106
|
// override the user's element selection with an extended matcher that looks for UIScrollView children
|
109
|
-
this.
|
107
|
+
this._matcher = this._matcher._extendToDescendantScrollViews();
|
110
108
|
|
111
109
|
const action = new actions.ScrollToIndex(index);
|
112
110
|
const traceDescription = actionDescription.scrollToIndex(index);
|
113
|
-
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
111
|
+
return await new ActionInteraction(this._invocationManager, this._matcher, action, traceDescription).execute();
|
114
112
|
}
|
115
113
|
|
116
114
|
async setDatePickerDate(rawDateString, formatString) {
|
@@ -120,7 +118,7 @@ class NativeElement {
|
|
120
118
|
|
121
119
|
const action = new actions.SetDatePickerDateAction(dateString, formatString);
|
122
120
|
const traceDescription = actionDescription.setDatePickerDate(dateString, formatString);
|
123
|
-
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
121
|
+
return await new ActionInteraction(this._invocationManager, this._matcher, action, traceDescription).execute();
|
124
122
|
}
|
125
123
|
|
126
124
|
/**
|
@@ -134,18 +132,18 @@ class NativeElement {
|
|
134
132
|
normalizedSwipeOffset = Number.isNaN(normalizedSwipeOffset) ? 0.75 : normalizedSwipeOffset;
|
135
133
|
|
136
134
|
// override the user's element selection with an extended matcher that avoids RN issues with RCTScrollView
|
137
|
-
this.
|
135
|
+
this._matcher = this._matcher._avoidProblematicReactNativeElements();
|
138
136
|
|
139
137
|
const action = new actions.SwipeAction(direction, speed, normalizedSwipeOffset, normalizedStartingPointX, normalizedStartingPointY);
|
140
138
|
const traceDescription = actionDescription.swipe(direction, speed, normalizedSwipeOffset, normalizedStartingPointX, normalizedStartingPointY);
|
141
|
-
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
139
|
+
return await new ActionInteraction(this._invocationManager, this._matcher, action, traceDescription).execute();
|
142
140
|
}
|
143
141
|
|
144
142
|
async takeScreenshot(screenshotName) {
|
145
143
|
// TODO this should be moved to a lower-layer handler of this use-case
|
146
144
|
const action = new actions.TakeElementScreenshot();
|
147
145
|
const traceDescription = actionDescription.takeScreenshot(screenshotName);
|
148
|
-
const resultBase64 = await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
146
|
+
const resultBase64 = await new ActionInteraction(this._invocationManager, this._matcher, action, traceDescription).execute();
|
149
147
|
const filePath = tempfile('detox.element-screenshot.png');
|
150
148
|
await fs.writeFile(filePath, resultBase64, 'base64');
|
151
149
|
|
@@ -160,19 +158,18 @@ class NativeElement {
|
|
160
158
|
async getAttributes() {
|
161
159
|
const action = new actions.GetAttributes();
|
162
160
|
const traceDescription = actionDescription.getAttributes();
|
163
|
-
|
164
|
-
return JSON.parse(result);
|
161
|
+
return await new ActionInteraction(this._invocationManager, this._matcher, action, traceDescription).execute();
|
165
162
|
}
|
166
163
|
|
167
164
|
async adjustSliderToPosition(newPosition) {
|
168
165
|
const action = new actions.AdjustSliderToPosition(newPosition);
|
169
166
|
const traceDescription = actionDescription.adjustSliderToPosition(newPosition);
|
170
|
-
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
167
|
+
return await new ActionInteraction(this._invocationManager, this._matcher, action, traceDescription).execute();
|
171
168
|
}
|
172
169
|
|
173
170
|
async performAccessibilityAction(actionName) {
|
174
171
|
const traceDescription = actionDescription.performAccessibilityAction(actionName);
|
175
|
-
return await new ActionInteraction(this._invocationManager, this, new actions.AccessibilityActionAction(actionName), traceDescription).execute();
|
172
|
+
return await new ActionInteraction(this._invocationManager, this._matcher, new actions.AccessibilityActionAction(actionName), traceDescription).execute();
|
176
173
|
}
|
177
174
|
}
|
178
175
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
const DetoxRuntimeError = require('../../errors/DetoxRuntimeError');
|
2
2
|
const invoke = require('../../invoke');
|
3
|
+
const assertIsFunction = require('../../utils/assertIsFunction');
|
4
|
+
const isArrowFunction = require('../../utils/isArrowFunction');
|
3
5
|
const actions = require('../actions/web');
|
4
6
|
const EspressoWebDetoxApi = require('../espressoapi/web/EspressoWebDetox');
|
5
7
|
const WebViewElementApi = require('../espressoapi/web/WebViewElement');
|
@@ -73,12 +75,14 @@ class WebElement {
|
|
73
75
|
return await new ActionInteraction(this[_invocationManager], new actions.WebMoveCursorEnd(this)).execute();
|
74
76
|
}
|
75
77
|
|
76
|
-
async runScript(
|
77
|
-
|
78
|
-
}
|
78
|
+
async runScript(maybeFunction, args) {
|
79
|
+
const script = stringifyScript(maybeFunction);
|
79
80
|
|
80
|
-
|
81
|
-
|
81
|
+
if (args) {
|
82
|
+
return await new ActionInteraction(this[_invocationManager], new actions.WebRunScriptWithArgsAction(this, script, args)).execute();
|
83
|
+
} else {
|
84
|
+
return await new ActionInteraction(this[_invocationManager], new actions.WebRunScriptAction(this, script)).execute();
|
85
|
+
}
|
82
86
|
}
|
83
87
|
|
84
88
|
async getCurrentUrl() {
|
@@ -116,10 +120,24 @@ class WebViewElement {
|
|
116
120
|
});
|
117
121
|
}
|
118
122
|
|
119
|
-
throw new DetoxRuntimeError(`element() argument is invalid, expected a web matcher, but got ${typeof
|
123
|
+
throw new DetoxRuntimeError(`element() argument is invalid, expected a web matcher, but got ${typeof webMatcher}`);
|
120
124
|
}
|
121
125
|
}
|
122
126
|
|
127
|
+
function stringifyScript(maybeFunction) {
|
128
|
+
if (typeof maybeFunction !== 'string' && typeof maybeFunction !== 'function') {
|
129
|
+
return maybeFunction;
|
130
|
+
}
|
131
|
+
|
132
|
+
const script = (typeof maybeFunction === 'function' ? maybeFunction.toString() : assertIsFunction(maybeFunction)).trim();
|
133
|
+
// WebElement interactions don't support arrow functions for some reason.
|
134
|
+
if (isArrowFunction(script)) {
|
135
|
+
return `function arrowWorkaround() { return (${script}).apply(this, arguments); }`;
|
136
|
+
}
|
137
|
+
|
138
|
+
return script;
|
139
|
+
}
|
140
|
+
|
123
141
|
module.exports = {
|
124
142
|
WebElement,
|
125
143
|
WebViewElement,
|
@@ -14,7 +14,7 @@ function sanitize_matcher(matcher) {
|
|
14
14
|
return originalMatcher.type ? originalMatcher.value : originalMatcher;
|
15
15
|
}
|
16
16
|
class DetoxAssertion {
|
17
|
-
static assertMatcher(
|
17
|
+
static assertMatcher(viewInteraction, viewMatcher) {
|
18
18
|
return {
|
19
19
|
target: {
|
20
20
|
type: "Class",
|
@@ -23,15 +23,15 @@ class DetoxAssertion {
|
|
23
23
|
method: "assertMatcher",
|
24
24
|
args: [{
|
25
25
|
type: "Invocation",
|
26
|
-
value:
|
26
|
+
value: viewInteraction
|
27
27
|
}, {
|
28
28
|
type: "Invocation",
|
29
|
-
value: sanitize_matcher(
|
29
|
+
value: sanitize_matcher(viewMatcher)
|
30
30
|
}]
|
31
31
|
};
|
32
32
|
}
|
33
33
|
|
34
|
-
static assertNotVisible(
|
34
|
+
static assertNotVisible(viewInteraction) {
|
35
35
|
return {
|
36
36
|
target: {
|
37
37
|
type: "Class",
|
@@ -40,12 +40,12 @@ class DetoxAssertion {
|
|
40
40
|
method: "assertNotVisible",
|
41
41
|
args: [{
|
42
42
|
type: "Invocation",
|
43
|
-
value:
|
43
|
+
value: viewInteraction
|
44
44
|
}]
|
45
45
|
};
|
46
46
|
}
|
47
47
|
|
48
|
-
static assertNotExists(
|
48
|
+
static assertNotExists(viewInteraction) {
|
49
49
|
return {
|
50
50
|
target: {
|
51
51
|
type: "Class",
|
@@ -54,12 +54,12 @@ class DetoxAssertion {
|
|
54
54
|
method: "assertNotExists",
|
55
55
|
args: [{
|
56
56
|
type: "Invocation",
|
57
|
-
value:
|
57
|
+
value: viewInteraction
|
58
58
|
}]
|
59
59
|
};
|
60
60
|
}
|
61
61
|
|
62
|
-
static waitForAssertMatcher(
|
62
|
+
static waitForAssertMatcher(viewInteraction, viewMatcher, timeoutSeconds) {
|
63
63
|
if (typeof timeoutSeconds !== "number") throw new Error("timeoutSeconds should be a number, but got " + (timeoutSeconds + (" (" + (typeof timeoutSeconds + ")"))));
|
64
64
|
return {
|
65
65
|
target: {
|
@@ -69,10 +69,10 @@ class DetoxAssertion {
|
|
69
69
|
method: "waitForAssertMatcher",
|
70
70
|
args: [{
|
71
71
|
type: "Invocation",
|
72
|
-
value:
|
72
|
+
value: viewInteraction
|
73
73
|
}, {
|
74
74
|
type: "Invocation",
|
75
|
-
value: sanitize_matcher(
|
75
|
+
value: sanitize_matcher(viewMatcher)
|
76
76
|
}, {
|
77
77
|
type: "Double",
|
78
78
|
value: timeoutSeconds
|
@@ -80,7 +80,8 @@ class DetoxAssertion {
|
|
80
80
|
};
|
81
81
|
}
|
82
82
|
|
83
|
-
static waitForAssertMatcherWithSearchAction(
|
83
|
+
static waitForAssertMatcherWithSearchAction(viewInteraction, viewMatcher, searchAction, searchMatcher
|
84
|
+
) {
|
84
85
|
return {
|
85
86
|
target: {
|
86
87
|
type: "Class",
|
@@ -89,13 +90,14 @@ class DetoxAssertion {
|
|
89
90
|
method: "waitForAssertMatcherWithSearchAction",
|
90
91
|
args: [{
|
91
92
|
type: "Invocation",
|
92
|
-
value:
|
93
|
+
value: viewInteraction
|
93
94
|
}, {
|
94
95
|
type: "Invocation",
|
95
|
-
value: sanitize_matcher(
|
96
|
+
value: sanitize_matcher(viewMatcher)
|
96
97
|
}, searchAction, {
|
97
98
|
type: "Invocation",
|
98
|
-
value: sanitize_matcher(searchMatcher
|
99
|
+
value: sanitize_matcher(searchMatcher
|
100
|
+
)
|
99
101
|
}]
|
100
102
|
};
|
101
103
|
}
|
@@ -5,9 +5,16 @@
|
|
5
5
|
*/
|
6
6
|
|
7
7
|
|
8
|
+
function sanitize_matcher(matcher) {
|
9
|
+
if (!matcher._call) {
|
10
|
+
return matcher;
|
11
|
+
}
|
8
12
|
|
13
|
+
const originalMatcher = typeof matcher._call === 'function' ? matcher._call() : matcher._call;
|
14
|
+
return originalMatcher.type ? originalMatcher.value : originalMatcher;
|
15
|
+
}
|
9
16
|
class EspressoDetox {
|
10
|
-
static perform(
|
17
|
+
static perform(matcher, action) {
|
11
18
|
return {
|
12
19
|
target: {
|
13
20
|
type: "Class",
|
@@ -16,7 +23,7 @@ class EspressoDetox {
|
|
16
23
|
method: "perform",
|
17
24
|
args: [{
|
18
25
|
type: "Invocation",
|
19
|
-
value:
|
26
|
+
value: sanitize_matcher(matcher)
|
20
27
|
}, action]
|
21
28
|
};
|
22
29
|
}
|
@@ -25,9 +25,9 @@ class Interaction {
|
|
25
25
|
}
|
26
26
|
|
27
27
|
class ActionInteraction extends Interaction {
|
28
|
-
constructor(invocationManager,
|
28
|
+
constructor(invocationManager, matcher, action, traceDescription) {
|
29
29
|
super(invocationManager, traceDescription);
|
30
|
-
this._call = EspressoDetoxApi.perform(
|
30
|
+
this._call = EspressoDetoxApi.perform(matcher, action._call);
|
31
31
|
// TODO: move this.execute() here from the caller
|
32
32
|
}
|
33
33
|
}
|
@@ -48,7 +48,6 @@ class WaitForInteraction extends Interaction {
|
|
48
48
|
super(invocationManager, expectTraceDescription);
|
49
49
|
this._element = element;
|
50
50
|
this._assertionMatcher = assertionMatcher;
|
51
|
-
this._element._selectElementWithMatcher(this._element._originalMatcher);
|
52
51
|
}
|
53
52
|
|
54
53
|
async withTimeout(timeout) {
|
@@ -4,7 +4,7 @@ class ArtifactPluginsProvider {
|
|
4
4
|
|
5
5
|
class AndroidArtifactPluginsProvider extends ArtifactPluginsProvider {
|
6
6
|
declareArtifactPlugins({ client }) {
|
7
|
-
const serviceLocator = require('../../servicelocator/android');
|
7
|
+
const serviceLocator = require('../../devices/servicelocator/android');
|
8
8
|
const adb = serviceLocator.adb;
|
9
9
|
const devicePathBuilder = serviceLocator.devicePathBuilder;
|
10
10
|
|
@@ -34,8 +34,8 @@ class IosArtifactPluginsProvider extends ArtifactPluginsProvider {
|
|
34
34
|
|
35
35
|
class IosSimulatorArtifactPluginsProvider extends IosArtifactPluginsProvider {
|
36
36
|
declareArtifactPlugins({ client }) {
|
37
|
-
const
|
38
|
-
const appleSimUtils =
|
37
|
+
const AppleSimUtils = require('../../devices/common/drivers/ios/tools/AppleSimUtils');
|
38
|
+
const appleSimUtils = new AppleSimUtils();
|
39
39
|
|
40
40
|
const SimulatorInstrumentsPlugin = require('../instruments/ios/SimulatorInstrumentsPlugin');
|
41
41
|
const SimulatorLogPlugin = require('../log/ios/SimulatorLogPlugin');
|
@@ -22,23 +22,6 @@ class SimulatorScreenshotPlugin extends ScreenshotArtifactPlugin {
|
|
22
22
|
}
|
23
23
|
}
|
24
24
|
|
25
|
-
async onBootDevice(event) {
|
26
|
-
await super.onBootDevice(event);
|
27
|
-
|
28
|
-
if (this.enabled && event.coldBoot) {
|
29
|
-
await this.appleSimUtils.takeScreenshot(event.deviceId, '/dev/null').catch(() => {
|
30
|
-
log.debug({}, `
|
31
|
-
NOTE: For an unknown yet reason, taking the first screenshot is apt
|
32
|
-
to fail when booting iOS Simulator in a hidden window mode (or on CI).
|
33
|
-
Detox applies a workaround by taking a dummy screenshot to ensure
|
34
|
-
that the future ones are going to work fine. This screenshot is not
|
35
|
-
saved anywhere, and the error above is suppressed for all log levels
|
36
|
-
except for "debug" and "trace."
|
37
|
-
`.trim());
|
38
|
-
});
|
39
|
-
}
|
40
|
-
}
|
41
|
-
|
42
25
|
async onBeforeUninstallApp(event) {
|
43
26
|
await this.api.requestIdleCallback(async () => {
|
44
27
|
const snapshots = [
|
@@ -32,6 +32,7 @@ function composeRunnerConfig(opts) {
|
|
32
32
|
retries: 0,
|
33
33
|
inspectBrk: inspectBrkHookDefault,
|
34
34
|
forwardEnv: false,
|
35
|
+
detached: false,
|
35
36
|
bail: false,
|
36
37
|
jest: {
|
37
38
|
setupTimeout: 300000,
|
@@ -56,8 +57,9 @@ function composeRunnerConfig(opts) {
|
|
56
57
|
|
57
58
|
if (typeof merged.inspectBrk === 'function') {
|
58
59
|
if (cliConfig.inspectBrk) {
|
59
|
-
merged.
|
60
|
+
merged.detached = false;
|
60
61
|
merged.forwardEnv = true;
|
62
|
+
merged.retries = 0;
|
61
63
|
merged.inspectBrk(merged);
|
62
64
|
}
|
63
65
|
|
@@ -1,43 +1,89 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
/**
|
2
|
+
* @typedef {import('./drivers/AllocationDriverBase').AllocationDriverBase} AllocationDriverBase
|
3
|
+
* @typedef {import('./drivers/AllocationDriverBase').DeallocOptions} DeallocOptions
|
4
|
+
* @typedef {import('../common/drivers/DeviceCookie').DeviceCookie} DeviceCookie
|
5
|
+
*/
|
6
|
+
|
7
|
+
const log = require('../../utils/logger').child({ cat: 'device,device-allocation' });
|
3
8
|
const traceMethods = require('../../utils/traceMethods');
|
4
9
|
|
5
10
|
class DeviceAllocator {
|
6
11
|
/**
|
7
|
-
* @param
|
12
|
+
* @param {AllocationDriverBase} allocationDriver
|
8
13
|
*/
|
9
14
|
constructor(allocationDriver) {
|
10
15
|
this._driver = allocationDriver;
|
11
|
-
|
16
|
+
this._counter = 0;
|
17
|
+
this._ids = new Map();
|
18
|
+
traceMethods(log, this, ['init', 'cleanup', 'emergencyCleanup']);
|
12
19
|
}
|
13
20
|
|
14
21
|
/**
|
15
|
-
* @
|
16
|
-
* @return {Promise<DeviceCookie>}
|
22
|
+
* @returns {Promise<void>}
|
17
23
|
*/
|
18
|
-
|
19
|
-
|
24
|
+
async init() {
|
25
|
+
if (typeof this._driver.init === 'function') {
|
26
|
+
await this._driver.init();
|
27
|
+
}
|
20
28
|
}
|
21
29
|
|
22
30
|
/**
|
23
|
-
* @param {
|
24
|
-
* @
|
31
|
+
* @param {Detox.DetoxDeviceConfig} deviceConfig
|
32
|
+
* @returns {Promise<DeviceCookie>}
|
25
33
|
*/
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
34
|
+
async allocate(deviceConfig) {
|
35
|
+
const tid = this._counter++;
|
36
|
+
return await log.trace.complete({ data: deviceConfig, id: tid }, 'allocate', async () => {
|
37
|
+
const cookie = await this._driver.allocate(deviceConfig);
|
38
|
+
log.debug({ data: cookie }, `settled on ${cookie.name || cookie.id}`);
|
39
|
+
this._ids.set(cookie.id, tid);
|
40
|
+
return cookie;
|
41
|
+
});
|
42
|
+
}
|
30
43
|
|
31
|
-
|
44
|
+
/**
|
45
|
+
* @param {DeviceCookie} cookie
|
46
|
+
* @returns {Promise<DeviceCookie>}
|
47
|
+
*/
|
48
|
+
async postAllocate(cookie) {
|
49
|
+
const tid = this._ids.get(cookie.id);
|
50
|
+
return await log.trace.complete({ data: cookie, id: tid }, `post-allocate: ${cookie.id}`, async () => {
|
51
|
+
const updatedCookie = typeof this._driver.postAllocate === 'function'
|
52
|
+
? await this._driver.postAllocate(cookie)
|
53
|
+
: undefined;
|
54
|
+
|
55
|
+
return updatedCookie || cookie;
|
56
|
+
});
|
32
57
|
}
|
33
58
|
|
34
59
|
/**
|
35
|
-
* @param
|
36
|
-
* @param
|
37
|
-
* @
|
60
|
+
* @param {DeviceCookie} cookie
|
61
|
+
* @param {DeallocOptions} options
|
62
|
+
* @returns {Promise<void>}
|
38
63
|
*/
|
39
|
-
free(cookie, options) {
|
40
|
-
|
64
|
+
async free(cookie, options = {}) {
|
65
|
+
const tid = this._ids.get(cookie.id);
|
66
|
+
await log.trace.complete({ data: options, id: tid }, `free: ${cookie.id}`, async () => {
|
67
|
+
await this._driver.free(cookie, options);
|
68
|
+
});
|
69
|
+
}
|
70
|
+
|
71
|
+
/**
|
72
|
+
* @returns {Promise<void>}
|
73
|
+
*/
|
74
|
+
async cleanup() {
|
75
|
+
if (typeof this._driver.cleanup === 'function') {
|
76
|
+
await this._driver.cleanup();
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
/**
|
81
|
+
* @returns {void}
|
82
|
+
*/
|
83
|
+
emergencyCleanup() {
|
84
|
+
if (typeof this._driver.emergencyCleanup === 'function') {
|
85
|
+
this._driver.emergencyCleanup();
|
86
|
+
}
|
41
87
|
}
|
42
88
|
}
|
43
89
|
|