detox 20.0.3-breaking.new-global-lifecycle.0 → 20.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/Detox-android/com/wix/detox/{20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar → 20.0.3/detox-20.0.3-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar → 20.0.3/detox-20.0.3-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.aar +0 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom → 20.0.3/detox-20.0.3.pom} +1 -7
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.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-src.tbz +0 -0
- package/Detox-ios.tbz +0 -0
- package/README.md +1 -1
- package/android/build.gradle +12 -7
- package/android/detox/build.gradle +13 -9
- package/android/detox/proguard-rules-app.pro +6 -0
- package/android/detox/proguard-rules.pro +3 -0
- package/android/detox/publishing.gradle +27 -27
- package/android/detox/src/full/java/com/wix/detox/DetoxCrashHandler.kt +1 -1
- package/android/detox/src/full/java/com/wix/detox/LaunchArgs.java +9 -0
- package/android/detox/src/full/java/com/wix/detox/TestEngineFacade.kt +1 -1
- package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeExtension.kt +15 -2
- package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeIdlingResources.kt +43 -38
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/IdlingResourceDescription.kt +19 -13
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResource.java +33 -30
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategy.kt +7 -27
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/IdleInterrogationStrategy.kt +1 -11
- package/android/detox/src/main/java/com/wix/detox/common/TextFileReader.kt +1 -1
- package/android/detox/src/testFull/java/com/wix/detox/espresso/action/DetoxMultiTapSpec.kt +4 -3
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResourcesTest.kt +61 -0
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategySpec.kt +3 -11
- package/index.d.ts +195 -59
- package/internals.d.ts +205 -43
- package/local-cli/build.js +1 -1
- package/local-cli/cli.js +11 -6
- package/local-cli/init.js +61 -21
- package/local-cli/rebuild-framework-cache.js +1 -1
- package/local-cli/reset-lock-file.js +16 -0
- package/local-cli/templates/jest.js +13 -10
- package/local-cli/test.js +14 -8
- package/local-cli/test.test.js +142 -61
- package/local-cli/testCommand/TestRunnerCommand.js +97 -77
- package/local-cli/testCommand/TestRunnerError.js +17 -0
- package/local-cli/testCommand/TestRunnerError.test.js +25 -0
- package/local-cli/testCommand/builder.js +0 -1
- package/local-cli/testCommand/middlewares.js +4 -13
- package/local-cli/testCommand/warnings.js +0 -3
- package/local-cli/utils/jestInternals.js +4 -1
- package/package.json +23 -18
- package/runners/deprecation.js +42 -44
- package/runners/jest/globalSetup.js +1 -1
- package/runners/jest/globalTeardown.js +1 -1
- package/runners/jest/index.d.ts +60 -0
- package/runners/jest/index.js +3 -8
- package/runners/jest/index.test.js +13 -0
- package/runners/jest/reporters/DetoxReporter.js +33 -2
- package/runners/jest/testEnvironment/index.js +119 -69
- package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +93 -46
- package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +1 -1
- package/runners/jest/testEnvironment/listeners/SpecReporter.js +13 -15
- package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +1 -5
- package/runners/jest/testEnvironment/utils/assertJestCircus27.js +17 -3
- package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +0 -1
- package/src/DetoxWorker.js +99 -62
- package/src/android/core/NativeElement.js +56 -20
- package/src/android/core/NativeExpect.js +28 -9
- package/src/android/interactions/native.js +25 -18
- package/src/artifacts/ArtifactsManager.js +14 -47
- package/src/artifacts/instruments/ios/SimulatorInstrumentsRecording.js +3 -3
- package/src/artifacts/log/ios/SimulatorLogRecording.js +1 -1
- package/src/artifacts/screenshot/SimulatorScreenshotPlugin.js +1 -1
- package/src/artifacts/templates/artifact/Artifact.js +1 -1
- package/src/artifacts/templates/plugin/ArtifactPlugin.js +1 -1
- package/src/artifacts/timeline/TimelineContextTypes.js +7 -0
- package/src/artifacts/utils/temporaryPath.js +49 -8
- package/src/artifacts/video/SimulatorRecordVideoPlugin.js +1 -1
- package/src/client/AsyncWebSocket.js +8 -17
- package/src/client/Client.js +19 -2
- package/src/client/actions/formatters/sync-resources/NetworkFormatter.js +1 -1
- package/src/configuration/collectCliConfig.js +1 -12
- package/src/configuration/composeAppsConfig.js +4 -0
- package/src/configuration/composeDeviceConfig.js +1 -1
- package/src/configuration/composeLoggerConfig.js +19 -10
- package/src/configuration/composeRunnerConfig.js +14 -9
- package/src/configuration/index.js +5 -1
- package/src/configuration/loadExternalConfig.js +1 -1
- package/src/devices/allocation/DeviceAllocator.js +3 -2
- package/src/devices/allocation/drivers/android/emulator/AVDValidator.js +5 -5
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +4 -3
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +6 -5
- package/src/devices/allocation/drivers/android/emulator/EmulatorVersionResolver.js +4 -6
- package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +4 -17
- package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +1 -1
- package/src/devices/common/drivers/android/exec/ADB.js +4 -0
- package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +3 -3
- package/src/devices/common/drivers/android/genycloud/services/GenyRecipesService.js +1 -1
- package/src/devices/common/drivers/android/tools/EmulatorTelnet.js +1 -1
- package/src/devices/common/drivers/android/tools/FreeDeviceFinder.js +1 -1
- package/src/devices/common/drivers/android/tools/MonitoredInstrumentation.js +1 -1
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +29 -3
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +13 -15
- package/src/devices/runtime/RuntimeDevice.js +19 -12
- package/src/devices/runtime/drivers/DeviceDriverBase.js +1 -1
- package/src/devices/runtime/drivers/android/AndroidDriver.js +10 -2
- package/src/devices/runtime/drivers/ios/SimulatorDriver.js +1 -1
- package/src/errors/DetoxConfigErrorComposer.js +14 -1
- package/src/errors/DetoxError.js +5 -1
- package/src/ios/expectTwo.js +153 -67
- package/src/ipc/IPCClient.js +12 -13
- package/src/ipc/IPCServer.js +28 -24
- package/src/ipc/{state.js → SessionState.js} +26 -53
- package/src/logger/DetoxLogger.js +287 -154
- package/src/logger/index.js +5 -0
- package/src/logger/utils/BunyanLogger.js +115 -0
- package/src/logger/utils/CategoryThreadDispatcher.js +37 -0
- package/src/logger/utils/DetoxLogFinalizer.js +162 -0
- package/src/logger/utils/MessageStack.js +35 -0
- package/src/logger/utils/ThreadDispatcher.js +61 -0
- package/src/logger/{customConsoleLogger.js → utils/customConsoleLogger.js} +23 -6
- package/src/logger/utils/getMainCategory.js +5 -0
- package/src/logger/utils/sanitizeBunyanContext.js +30 -0
- package/src/logger/utils/streams/BunyanTransformer.js +72 -0
- package/src/logger/utils/streams/ChromeTraceTransformer.js +127 -0
- package/src/logger/utils/streams/DetoxJSONLParser.js +31 -0
- package/src/logger/utils/streams/JSONLStringer.js +55 -0
- package/src/logger/utils/streams/index.js +7 -0
- package/src/logger/utils/streams/transformers.js +39 -0
- package/src/logger/utils/tracerLegacy.js +37 -0
- package/src/realms/DetoxContext.js +79 -65
- package/src/realms/DetoxInternalsFacade.js +8 -12
- package/src/realms/DetoxPrimaryContext.js +104 -70
- package/src/realms/DetoxSecondaryContext.js +29 -32
- package/src/server/DetoxConnection.js +18 -23
- package/src/server/DetoxServer.js +7 -10
- package/src/server/DetoxSession.js +6 -6
- package/src/server/DetoxSessionManager.js +1 -1
- package/src/server/handlers/RegisteredConnectionHandler.js +1 -2
- package/src/symbols.js +16 -22
- package/src/utils/Timer.js +55 -38
- package/src/utils/argparse.js +11 -0
- package/src/utils/childProcess/exec.js +1 -1
- package/src/utils/childProcess/spawn.js +1 -1
- package/src/utils/errorUtils.js +24 -3
- package/src/utils/invocationTraceDescriptions.js +43 -0
- package/src/utils/logger.js +1 -1
- package/src/utils/pathUtils.js +11 -0
- package/src/utils/shellUtils.js +17 -0
- package/src/utils/traceInvocationCall.js +21 -0
- package/src/utils/traceMethods.js +15 -0
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom.sha512 +0 -1
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DefaultIdleInterrogationStrategy.kt +0 -84
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DefaultIdleInterrogationStrategySpec.kt +0 -115
- package/runners/jest/deprecation.js +0 -25
- package/src/configuration/utils/warnings.js +0 -12
- package/src/logger/DetoxTraceEventBuilder.js +0 -21
- package/src/logger/DetoxTracer.js +0 -133
- package/src/logger/TraceThreadDispatcher.js +0 -52
- package/src/utils/ChromeTracingExporter.js +0 -54
- package/src/utils/streamUtils.js +0 -214
- package/src/utils/trace.js +0 -19
package/src/DetoxWorker.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
const CAF = require('caf');
|
1
2
|
const _ = require('lodash');
|
2
3
|
|
3
4
|
const Client = require('./client/Client');
|
@@ -11,7 +12,7 @@ const uuid = require('./utils/uuid');
|
|
11
12
|
class DetoxWorker {
|
12
13
|
constructor(context) {
|
13
14
|
this._context = context;
|
14
|
-
this.
|
15
|
+
this._injectedGlobalProperties = [];
|
15
16
|
this._config = context[symbols.config];
|
16
17
|
this._runtimeErrorComposer = new DetoxRuntimeErrorComposer(this._config);
|
17
18
|
this._client = null;
|
@@ -32,6 +33,20 @@ class DetoxWorker {
|
|
32
33
|
onError: this._onEmitError.bind(this),
|
33
34
|
});
|
34
35
|
|
36
|
+
|
37
|
+
/** @type {DetoxInternals.RuntimeConfig['apps']} */
|
38
|
+
this._appsConfig = null;
|
39
|
+
/** @type {DetoxInternals.RuntimeConfig['artifacts']} */
|
40
|
+
this._artifactsConfig = null;
|
41
|
+
/** @type {DetoxInternals.RuntimeConfig['behavior']} */
|
42
|
+
this._behaviorConfig = null;
|
43
|
+
/** @type {DetoxInternals.RuntimeConfig['device']} */
|
44
|
+
this._deviceConfig = null;
|
45
|
+
/** @type {DetoxInternals.RuntimeConfig['session']} */
|
46
|
+
this._sessionConfig = null;
|
47
|
+
|
48
|
+
/** @type {string} */
|
49
|
+
this.id = 'worker';
|
35
50
|
/** @type {Detox.Device} */
|
36
51
|
this.device = null;
|
37
52
|
/** @type {Detox.ElementFacade} */
|
@@ -51,11 +66,23 @@ class DetoxWorker {
|
|
51
66
|
this.trace = this._context.trace;
|
52
67
|
/** @deprecated */
|
53
68
|
this.traceCall = this._context.traceCall;
|
54
|
-
}
|
55
69
|
|
56
|
-
|
57
|
-
|
70
|
+
this._reinstallAppsOnDevice = CAF(this._reinstallAppsOnDevice.bind(this));
|
71
|
+
this._initToken = new CAF.cancelToken();
|
72
|
+
|
73
|
+
this._cafWrap([
|
74
|
+
'init',
|
75
|
+
'onRunDescribeStart',
|
76
|
+
'onTestStart',
|
77
|
+
'onHookFailure',
|
78
|
+
'onTestFnFailure',
|
79
|
+
'onTestDone',
|
80
|
+
'onRunDescribeFinish',
|
81
|
+
]);
|
82
|
+
}
|
58
83
|
|
84
|
+
/** @this {DetoxWorker} */
|
85
|
+
init = function* (signal) {
|
59
86
|
const {
|
60
87
|
apps: appsConfig,
|
61
88
|
artifacts: artifactsConfig,
|
@@ -63,14 +90,16 @@ class DetoxWorker {
|
|
63
90
|
device: deviceConfig,
|
64
91
|
session: sessionConfig
|
65
92
|
} = this._config;
|
93
|
+
|
66
94
|
this._appsConfig = appsConfig;
|
67
95
|
this._artifactsConfig = artifactsConfig;
|
68
96
|
this._behaviorConfig = behaviorConfig;
|
69
97
|
this._deviceConfig = deviceConfig;
|
70
98
|
this._sessionConfig = sessionConfig;
|
99
|
+
// @ts-ignore
|
100
|
+
this._sessionConfig.sessionId = sessionConfig.sessionId || uuid.UUID();
|
71
101
|
this._runtimeErrorComposer.appsConfig = this._appsConfig;
|
72
102
|
|
73
|
-
sessionConfig.sessionId = sessionConfig.sessionId || uuid.UUID();
|
74
103
|
this._client = new Client(sessionConfig);
|
75
104
|
this._client.terminateApp = async () => {
|
76
105
|
// @ts-ignore
|
@@ -79,8 +108,7 @@ class DetoxWorker {
|
|
79
108
|
}
|
80
109
|
};
|
81
110
|
|
82
|
-
|
83
|
-
if (this._isCleaningUp) return;
|
111
|
+
yield this._client.connect();
|
84
112
|
|
85
113
|
const invocationManager = new InvocationManager(this._client);
|
86
114
|
|
@@ -97,8 +125,7 @@ class DetoxWorker {
|
|
97
125
|
} = environmentFactory.createFactories(this._deviceConfig);
|
98
126
|
|
99
127
|
const envValidator = envValidatorFactory.createValidator();
|
100
|
-
|
101
|
-
if (this._isCleaningUp) return;
|
128
|
+
yield envValidator.validate();
|
102
129
|
|
103
130
|
const commonDeps = {
|
104
131
|
invocationManager,
|
@@ -109,8 +136,7 @@ class DetoxWorker {
|
|
109
136
|
|
110
137
|
this._artifactsManager = artifactsManagerFactory.createArtifactsManager(this._artifactsConfig, commonDeps);
|
111
138
|
this._deviceAllocator = deviceAllocatorFactory.createDeviceAllocator(commonDeps);
|
112
|
-
this._deviceCookie =
|
113
|
-
if (this._isCleaningUp) return;
|
139
|
+
this._deviceCookie = yield this._deviceAllocator.allocate(this._deviceConfig);
|
114
140
|
|
115
141
|
this.device = runtimeDeviceFactory.createRuntimeDevice(
|
116
142
|
this._deviceCookie,
|
@@ -121,7 +147,6 @@ class DetoxWorker {
|
|
121
147
|
deviceConfig: this._deviceConfig,
|
122
148
|
sessionConfig,
|
123
149
|
});
|
124
|
-
if (this._isCleaningUp) return;
|
125
150
|
|
126
151
|
const matchers = matchersFactory.createMatchers({
|
127
152
|
invocationManager,
|
@@ -131,34 +156,37 @@ class DetoxWorker {
|
|
131
156
|
Object.assign(this, matchers);
|
132
157
|
|
133
158
|
if (behaviorConfig.init.exposeGlobals) {
|
134
|
-
|
159
|
+
const injectedGlobals = {
|
135
160
|
...matchers,
|
136
161
|
device: this.device,
|
137
162
|
detox: this,
|
138
|
-
}
|
163
|
+
};
|
164
|
+
|
165
|
+
this._injectedGlobalProperties = Object.keys(injectedGlobals);
|
166
|
+
Object.assign(DetoxWorker.global, injectedGlobals);
|
139
167
|
}
|
140
168
|
|
141
169
|
// @ts-ignore
|
142
|
-
|
143
|
-
if (this._isCleaningUp) return;
|
170
|
+
yield this.device.installUtilBinaries();
|
144
171
|
|
145
172
|
if (behaviorConfig.init.reinstallApp) {
|
146
|
-
|
147
|
-
if (this._isCleaningUp) return;
|
173
|
+
yield this._reinstallAppsOnDevice(signal);
|
148
174
|
}
|
149
175
|
|
150
176
|
const appAliases = Object.keys(this._appsConfig);
|
151
177
|
if (appAliases.length === 1) {
|
152
|
-
|
178
|
+
yield this.device.selectApp(appAliases[0]);
|
153
179
|
} else {
|
154
|
-
|
180
|
+
yield this.device.selectApp(null);
|
155
181
|
}
|
156
|
-
|
157
|
-
return this;
|
158
|
-
}
|
182
|
+
};
|
159
183
|
|
160
184
|
async cleanup() {
|
161
|
-
this.
|
185
|
+
this._initToken.abort('CLEANUP');
|
186
|
+
|
187
|
+
for (const key of this._injectedGlobalProperties) {
|
188
|
+
delete DetoxWorker.global[key];
|
189
|
+
}
|
162
190
|
|
163
191
|
if (this._artifactsManager) {
|
164
192
|
await this._artifactsManager.onBeforeCleanup();
|
@@ -187,46 +215,45 @@ class DetoxWorker {
|
|
187
215
|
return this._context.log;
|
188
216
|
}
|
189
217
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
218
|
+
onRunDescribeStart = function* (_signal, ...args) {
|
219
|
+
yield this._artifactsManager.onRunDescribeStart(...args);
|
220
|
+
};
|
221
|
+
|
222
|
+
onTestStart = function* (_signal, testSummary) {
|
194
223
|
this._validateTestSummary('beforeEach', testSummary);
|
195
|
-
this._logTestRunCheckpoint('DETOX_BEFORE_EACH', testSummary);
|
196
224
|
|
197
|
-
|
198
|
-
await this._dumpUnhandledErrorsIfAny({
|
225
|
+
yield this._dumpUnhandledErrorsIfAny({
|
199
226
|
pendingRequests: false,
|
200
227
|
testName: testSummary.fullName,
|
201
228
|
});
|
202
229
|
|
203
|
-
|
204
|
-
|
230
|
+
yield this._artifactsManager.onTestStart(testSummary);
|
231
|
+
};
|
232
|
+
|
233
|
+
onHookFailure = function* (_signal, ...args) {
|
234
|
+
yield this._artifactsManager.onHookFailure(...args);
|
205
235
|
};
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
onTestDone = async (testSummary) => {
|
213
|
-
if (this._isCleaningUp) return;
|
236
|
+
|
237
|
+
onTestFnFailure = function* (_signal, ...args) {
|
238
|
+
yield this._artifactsManager.onTestFnFailure(...args);
|
239
|
+
};
|
240
|
+
|
241
|
+
onTestDone = function* (_signal, testSummary) {
|
214
242
|
this._validateTestSummary('afterEach', testSummary);
|
215
|
-
this._logTestRunCheckpoint('DETOX_AFTER_EACH', testSummary);
|
216
243
|
|
217
|
-
|
218
|
-
await this._artifactsManager.onTestDone(testSummary);
|
244
|
+
yield this._artifactsManager.onTestDone(testSummary);
|
219
245
|
|
220
|
-
|
221
|
-
await this._dumpUnhandledErrorsIfAny({
|
246
|
+
yield this._dumpUnhandledErrorsIfAny({
|
222
247
|
pendingRequests: testSummary.timedOut,
|
223
248
|
testName: testSummary.fullName,
|
224
249
|
});
|
225
250
|
};
|
226
|
-
onRunDescribeFinish = async (...args) => this._artifactsManager.onRunDescribeFinish(...args);
|
227
|
-
onRunFinish = async (...args) => this._artifactsManager.onRunFinish(...args);
|
228
251
|
|
229
|
-
|
252
|
+
onRunDescribeFinish = function* (_signal, ...args) {
|
253
|
+
yield this._artifactsManager.onRunDescribeFinish(...args);
|
254
|
+
};
|
255
|
+
|
256
|
+
*_reinstallAppsOnDevice(_signal) {
|
230
257
|
const appNames = _(this._appsConfig)
|
231
258
|
.map((config, key) => [key, `${config.binaryPath}:${config.testBinaryPath}`])
|
232
259
|
.uniqBy(1)
|
@@ -234,24 +261,16 @@ class DetoxWorker {
|
|
234
261
|
.value();
|
235
262
|
|
236
263
|
for (const appName of appNames) {
|
237
|
-
|
238
|
-
|
239
|
-
await this.device.uninstallApp();
|
240
|
-
if (this._isCleaningUp) return;
|
264
|
+
yield this.device.selectApp(appName);
|
265
|
+
yield this.device.uninstallApp();
|
241
266
|
}
|
242
267
|
|
243
268
|
for (const appName of appNames) {
|
244
|
-
|
245
|
-
|
246
|
-
await this.device.installApp();
|
247
|
-
if (this._isCleaningUp) return;
|
269
|
+
yield this.device.selectApp(appName);
|
270
|
+
yield this.device.installApp();
|
248
271
|
}
|
249
272
|
}
|
250
273
|
|
251
|
-
_logTestRunCheckpoint(event, { status, fullName }) {
|
252
|
-
this.log.trace({ event, status }, `${status} test: ${JSON.stringify(fullName)}`);
|
253
|
-
}
|
254
|
-
|
255
274
|
_validateTestSummary(methodName, testSummary) {
|
256
275
|
if (!_.isPlainObject(testSummary)) {
|
257
276
|
throw this._runtimeErrorComposer.invalidTestSummary(methodName, testSummary);
|
@@ -280,10 +299,28 @@ class DetoxWorker {
|
|
280
299
|
error
|
281
300
|
);
|
282
301
|
}
|
302
|
+
|
303
|
+
_cafWrap(methodNames) {
|
304
|
+
for (const methodName of methodNames) {
|
305
|
+
const cafMethod = CAF(this[methodName].bind(this));
|
306
|
+
this[methodName] = async (...args) => {
|
307
|
+
try {
|
308
|
+
await cafMethod(this._initToken.signal, ...args);
|
309
|
+
} catch (e) {
|
310
|
+
if (e !== 'CLEANUP') {
|
311
|
+
throw e;
|
312
|
+
}
|
313
|
+
}
|
314
|
+
|
315
|
+
return this;
|
316
|
+
};
|
317
|
+
}
|
318
|
+
}
|
319
|
+
|
283
320
|
}
|
284
321
|
|
285
322
|
/**
|
286
|
-
* @type {NodeJS.Global}
|
323
|
+
* @type {NodeJS.Global | {}}
|
287
324
|
*/
|
288
325
|
DetoxWorker.global = global;
|
289
326
|
|
@@ -5,6 +5,7 @@ const tempfile = require('tempfile');
|
|
5
5
|
|
6
6
|
const DetoxRuntimeError = require('../../errors/DetoxRuntimeError');
|
7
7
|
const invoke = require('../../invoke');
|
8
|
+
const { actionDescription } = require('../../utils/invocationTraceDescriptions');
|
8
9
|
const actions = require('../actions/native');
|
9
10
|
const DetoxMatcherApi = require('../espressoapi/DetoxMatcher');
|
10
11
|
const { ActionInteraction } = require('../interactions/native');
|
@@ -18,12 +19,11 @@ class NativeElement {
|
|
18
19
|
}
|
19
20
|
|
20
21
|
_selectElementWithMatcher(matcher) {
|
21
|
-
// if (!(matcher instanceof NativeMatcher)) throw new DetoxRuntimeError(`Element _selectElementWithMatcher argument must be a valid NativeMatcher, got ${typeof matcher}`);
|
22
22
|
this._call = invoke.call(invoke.Espresso, 'onView', matcher._call);
|
23
23
|
}
|
24
24
|
|
25
25
|
atIndex(index) {
|
26
|
-
if (typeof index !== 'number') throw new DetoxRuntimeError(`Element atIndex argument must be a number, got ${typeof index}`);
|
26
|
+
if (typeof index !== 'number') throw new DetoxRuntimeError({ message: `Element atIndex argument must be a number, got ${typeof index}` });
|
27
27
|
const matcher = this._originalMatcher;
|
28
28
|
this._originalMatcher._call = invoke.callDirectly(DetoxMatcherApi.matcherForAtIndex(index, matcher._call.value));
|
29
29
|
|
@@ -32,56 +32,84 @@ class NativeElement {
|
|
32
32
|
}
|
33
33
|
|
34
34
|
async tap(value) {
|
35
|
-
|
35
|
+
const action = new actions.TapAction(value);
|
36
|
+
const traceDescription = actionDescription.tapAtPoint(value);
|
37
|
+
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
36
38
|
}
|
37
39
|
|
38
40
|
async tapAtPoint(value) {
|
39
|
-
|
41
|
+
const action = new actions.TapAtPointAction(value);
|
42
|
+
const traceDescription = actionDescription.tapAtPoint(value);
|
43
|
+
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
40
44
|
}
|
41
45
|
|
42
46
|
async longPress() {
|
43
|
-
|
47
|
+
const action = new actions.LongPressAction();
|
48
|
+
const traceDescription = actionDescription.longPress();
|
49
|
+
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
44
50
|
}
|
45
51
|
|
46
52
|
async multiTap(times) {
|
47
|
-
|
53
|
+
if (typeof times !== 'number') throw new Error('times should be a number, but got ' + (times + (' (' + (typeof times + ')'))));
|
54
|
+
if (times < 1) throw new Error('times should be greater than 0, but got ' + times);
|
55
|
+
|
56
|
+
const action = new actions.MultiClickAction(times);
|
57
|
+
const traceDescription = actionDescription.multiTap(times);
|
58
|
+
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
48
59
|
}
|
49
60
|
|
50
61
|
async tapBackspaceKey() {
|
51
|
-
|
62
|
+
const action = new actions.PressKeyAction(67);
|
63
|
+
const traceDescription = actionDescription.tapBackspaceKey();
|
64
|
+
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
52
65
|
}
|
53
66
|
|
54
67
|
async tapReturnKey() {
|
55
|
-
|
68
|
+
const action = new actions.TypeTextAction('\n');
|
69
|
+
const traceDescription = actionDescription.tapReturnKey();
|
70
|
+
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
56
71
|
}
|
57
72
|
|
58
73
|
async typeText(value) {
|
59
|
-
|
74
|
+
const action = new actions.TypeTextAction(value);
|
75
|
+
const traceDescription = actionDescription.typeText(value);
|
76
|
+
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
60
77
|
}
|
61
78
|
|
62
79
|
async replaceText(value) {
|
63
|
-
|
80
|
+
const action = new actions.ReplaceTextAction(value);
|
81
|
+
const traceDescription = actionDescription.replaceText(value);
|
82
|
+
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
64
83
|
}
|
65
84
|
|
66
85
|
async clearText() {
|
67
|
-
|
86
|
+
const action = new actions.ClearTextAction();
|
87
|
+
const traceDescription = actionDescription.clearText();
|
88
|
+
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
68
89
|
}
|
69
90
|
|
70
91
|
async scroll(amount, direction = 'down', startPositionX, startPositionY) {
|
71
|
-
|
72
|
-
|
73
|
-
return await new ActionInteraction(this._invocationManager, this,
|
92
|
+
const action = new actions.ScrollAmountAction(direction, amount, startPositionX, startPositionY);
|
93
|
+
const traceDescription = actionDescription.scroll(amount, direction, startPositionX, startPositionY);
|
94
|
+
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
74
95
|
}
|
75
96
|
|
76
97
|
async scrollTo(edge) {
|
77
98
|
// override the user's element selection with an extended matcher that looks for UIScrollView children
|
78
99
|
this._selectElementWithMatcher(this._originalMatcher._extendToDescendantScrollViews());
|
79
|
-
|
100
|
+
|
101
|
+
const action = new actions.ScrollEdgeAction(edge);
|
102
|
+
const traceDescription = actionDescription.scrollTo(edge);
|
103
|
+
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
80
104
|
}
|
81
105
|
|
82
106
|
async scrollToIndex(index) {
|
107
|
+
// override the user's element selection with an extended matcher that looks for UIScrollView children
|
83
108
|
this._selectElementWithMatcher(this._originalMatcher._extendToDescendantScrollViews());
|
84
|
-
|
109
|
+
|
110
|
+
const action = new actions.ScrollToIndex(index);
|
111
|
+
const traceDescription = actionDescription.scrollToIndex(index);
|
112
|
+
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
85
113
|
}
|
86
114
|
|
87
115
|
/**
|
@@ -96,13 +124,17 @@ class NativeElement {
|
|
96
124
|
|
97
125
|
// override the user's element selection with an extended matcher that avoids RN issues with RCTScrollView
|
98
126
|
this._selectElementWithMatcher(this._originalMatcher._avoidProblematicReactNativeElements());
|
127
|
+
|
99
128
|
const action = new actions.SwipeAction(direction, speed, normalizedSwipeOffset, normalizedStartingPointX, normalizedStartingPointY);
|
100
|
-
|
129
|
+
const traceDescription = actionDescription.swipe(direction, speed, normalizedSwipeOffset, normalizedStartingPointX, normalizedStartingPointY);
|
130
|
+
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
101
131
|
}
|
102
132
|
|
103
133
|
async takeScreenshot(screenshotName) {
|
104
134
|
// TODO this should be moved to a lower-layer handler of this use-case
|
105
|
-
const
|
135
|
+
const action = new actions.TakeElementScreenshot();
|
136
|
+
const traceDescription = actionDescription.takeScreenshot(screenshotName);
|
137
|
+
const resultBase64 = await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
106
138
|
const filePath = tempfile('detox.element-screenshot.png');
|
107
139
|
await fs.writeFile(filePath, resultBase64, 'base64');
|
108
140
|
|
@@ -115,12 +147,16 @@ class NativeElement {
|
|
115
147
|
}
|
116
148
|
|
117
149
|
async getAttributes() {
|
118
|
-
const
|
150
|
+
const action = new actions.GetAttributes();
|
151
|
+
const traceDescription = actionDescription.getAttributes();
|
152
|
+
const result = await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
119
153
|
return JSON.parse(result);
|
120
154
|
}
|
121
155
|
|
122
156
|
async adjustSliderToPosition(newPosition) {
|
123
|
-
|
157
|
+
const action = new actions.AdjustSliderToPosition(newPosition);
|
158
|
+
const traceDescription = actionDescription.adjustSliderToPosition(newPosition);
|
159
|
+
return await new ActionInteraction(this._invocationManager, this, action, traceDescription).execute();
|
124
160
|
}
|
125
161
|
}
|
126
162
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
const { expectDescription } = require('../../utils/invocationTraceDescriptions');
|
1
2
|
const { MatcherAssertionInteraction } = require('../interactions/native');
|
2
3
|
const matchers = require('../matchers/native');
|
3
4
|
|
@@ -19,7 +20,9 @@ class NativeExpectElement extends NativeExpect {
|
|
19
20
|
}
|
20
21
|
|
21
22
|
async toBeVisible(pct) {
|
22
|
-
|
23
|
+
const matcher = new matchers.VisibleMatcher(pct);
|
24
|
+
const traceDescription = expectDescription.toBeVisible(pct);
|
25
|
+
return await new MatcherAssertionInteraction(this._invocationManager, this._element, matcher, this._notCondition, traceDescription).execute();
|
23
26
|
}
|
24
27
|
|
25
28
|
async toBeNotVisible() {
|
@@ -27,7 +30,9 @@ class NativeExpectElement extends NativeExpect {
|
|
27
30
|
}
|
28
31
|
|
29
32
|
async toExist() {
|
30
|
-
|
33
|
+
const matcher = new matchers.ExistsMatcher();
|
34
|
+
const traceDescription = expectDescription.toExist();
|
35
|
+
return await new MatcherAssertionInteraction(this._invocationManager, this._element, matcher, this._notCondition, traceDescription).execute();
|
31
36
|
}
|
32
37
|
|
33
38
|
async toNotExist() {
|
@@ -35,7 +40,9 @@ class NativeExpectElement extends NativeExpect {
|
|
35
40
|
}
|
36
41
|
|
37
42
|
async toHaveText(text) {
|
38
|
-
|
43
|
+
const matcher = new matchers.TextMatcher(text);
|
44
|
+
const traceDescription = expectDescription.toHaveText(text);
|
45
|
+
return await new MatcherAssertionInteraction(this._invocationManager, this._element, matcher, this._notCondition, traceDescription).execute();
|
39
46
|
}
|
40
47
|
|
41
48
|
async toNotHaveText(text) {
|
@@ -43,7 +50,9 @@ class NativeExpectElement extends NativeExpect {
|
|
43
50
|
}
|
44
51
|
|
45
52
|
async toHaveLabel(value) {
|
46
|
-
|
53
|
+
const matcher = new matchers.LabelMatcher(value);
|
54
|
+
const traceDescription = expectDescription.toHaveLabel(value);
|
55
|
+
return await new MatcherAssertionInteraction(this._invocationManager, this._element, matcher, this._notCondition, traceDescription).execute();
|
47
56
|
}
|
48
57
|
|
49
58
|
async toNotHaveLabel(value) {
|
@@ -51,7 +60,9 @@ class NativeExpectElement extends NativeExpect {
|
|
51
60
|
}
|
52
61
|
|
53
62
|
async toHaveId(value) {
|
54
|
-
|
63
|
+
const matcher = new matchers.IdMatcher(value);
|
64
|
+
const traceDescription = expectDescription.toHaveId(value);
|
65
|
+
return await new MatcherAssertionInteraction(this._invocationManager, this._element, matcher, this._notCondition, traceDescription).execute();
|
55
66
|
}
|
56
67
|
|
57
68
|
async toNotHaveId(value) {
|
@@ -59,7 +70,9 @@ class NativeExpectElement extends NativeExpect {
|
|
59
70
|
}
|
60
71
|
|
61
72
|
async toHaveValue(value) {
|
62
|
-
|
73
|
+
const matcher = new matchers.ValueMatcher(value);
|
74
|
+
const traceDescription = expectDescription.toHaveValue(value);
|
75
|
+
return await new MatcherAssertionInteraction(this._invocationManager, this._element, matcher, this._notCondition, traceDescription).execute();
|
63
76
|
}
|
64
77
|
|
65
78
|
async toNotHaveValue(value) {
|
@@ -67,15 +80,21 @@ class NativeExpectElement extends NativeExpect {
|
|
67
80
|
}
|
68
81
|
|
69
82
|
async toHaveToggleValue(value) {
|
70
|
-
|
83
|
+
const matcher = new matchers.ToggleMatcher(value);
|
84
|
+
const traceDescription = expectDescription.toHaveToggleValue(value);
|
85
|
+
return await new MatcherAssertionInteraction(this._invocationManager, this._element, matcher, this._notCondition, traceDescription).execute();
|
71
86
|
}
|
72
87
|
|
73
88
|
async toHaveSliderPosition(value, tolerance = 0) {
|
74
|
-
|
89
|
+
const matcher = new matchers.SliderPositionMatcher(value, tolerance);
|
90
|
+
const traceDescription = expectDescription.toHaveSliderPosition(value, tolerance);
|
91
|
+
return await new MatcherAssertionInteraction(this._invocationManager, this._element, matcher, this._notCondition, traceDescription).execute();
|
75
92
|
}
|
76
93
|
|
77
94
|
async toBeFocused() {
|
78
|
-
|
95
|
+
const matcher = new matchers.FocusMatcher();
|
96
|
+
const traceDescription = expectDescription.toBeFocused();
|
97
|
+
return await new MatcherAssertionInteraction(this._invocationManager, this._element, matcher, this._notCondition, traceDescription).execute();
|
79
98
|
}
|
80
99
|
|
81
100
|
async toBeNotFocused() {
|
@@ -1,4 +1,7 @@
|
|
1
1
|
const DetoxRuntimeError = require('../../errors/DetoxRuntimeError');
|
2
|
+
const { expectDescription, actionDescription } = require('../../utils/invocationTraceDescriptions');
|
3
|
+
const log = require('../../utils/logger').child({ cat: 'ws-client, ws' });
|
4
|
+
const traceInvocationCall = require('../../utils/traceInvocationCall').bind(null, log);
|
2
5
|
const { ScrollAmountStopAtEdgeAction } = require('../actions/native');
|
3
6
|
const { NativeMatcher } = require('../core/NativeMatcher');
|
4
7
|
const DetoxAssertionApi = require('../espressoapi/DetoxAssertion');
|
@@ -9,45 +12,50 @@ function call(maybeAFunction) {
|
|
9
12
|
}
|
10
13
|
|
11
14
|
class Interaction {
|
12
|
-
constructor(invocationManager) {
|
15
|
+
constructor(invocationManager, traceDescription) {
|
13
16
|
this._call = undefined;
|
17
|
+
this._traceDescription = traceDescription;
|
14
18
|
this._invocationManager = invocationManager;
|
15
19
|
}
|
16
20
|
|
17
21
|
async execute() {
|
18
|
-
|
19
|
-
|
22
|
+
return traceInvocationCall(this._traceDescription, this._call,
|
23
|
+
this._invocationManager.execute(this._call).then((resultObj) => resultObj ? resultObj.result : undefined));
|
20
24
|
}
|
21
25
|
}
|
22
26
|
|
23
27
|
class ActionInteraction extends Interaction {
|
24
|
-
constructor(invocationManager, element, action) {
|
25
|
-
super(invocationManager);
|
28
|
+
constructor(invocationManager, element, action, traceDescription) {
|
29
|
+
super(invocationManager, traceDescription);
|
26
30
|
this._call = EspressoDetoxApi.perform(call(element._call), action._call);
|
27
31
|
// TODO: move this.execute() here from the caller
|
28
32
|
}
|
29
33
|
}
|
30
34
|
|
31
35
|
class MatcherAssertionInteraction extends Interaction {
|
32
|
-
constructor(invocationManager, element, matcher) {
|
33
|
-
|
36
|
+
constructor(invocationManager, element, matcher, notCondition, traceDescription) {
|
37
|
+
traceDescription = expectDescription.full(traceDescription, notCondition);
|
38
|
+
super(invocationManager, traceDescription);
|
39
|
+
|
40
|
+
matcher = notCondition ? matcher.not : matcher;
|
34
41
|
this._call = DetoxAssertionApi.assertMatcher(call(element._call), matcher._call.value);
|
35
42
|
// TODO: move this.execute() here from the caller
|
36
43
|
}
|
37
44
|
}
|
38
45
|
|
39
46
|
class WaitForInteraction extends Interaction {
|
40
|
-
constructor(invocationManager, element, assertionMatcher) {
|
41
|
-
super(invocationManager);
|
47
|
+
constructor(invocationManager, element, assertionMatcher, expectTraceDescription) {
|
48
|
+
super(invocationManager, expectTraceDescription);
|
42
49
|
this._element = element;
|
43
50
|
this._assertionMatcher = assertionMatcher;
|
44
51
|
this._element._selectElementWithMatcher(this._element._originalMatcher);
|
45
52
|
}
|
46
53
|
|
47
54
|
async withTimeout(timeout) {
|
48
|
-
if (typeof timeout !== 'number') throw new DetoxRuntimeError(`WaitForInteraction withTimeout argument must be a number, got ${typeof timeout}`);
|
49
|
-
if (timeout < 0) throw new DetoxRuntimeError('timeout must be larger than 0');
|
55
|
+
if (typeof timeout !== 'number') throw new DetoxRuntimeError({ message: `WaitForInteraction withTimeout argument must be a number, got ${typeof timeout}` });
|
56
|
+
if (timeout < 0) throw new DetoxRuntimeError({ message: 'timeout must be larger than 0' });
|
50
57
|
|
58
|
+
this._traceDescription = expectDescription.waitForWithTimeout(this._traceDescription, timeout);
|
51
59
|
this._call = DetoxAssertionApi.waitForAssertMatcher(call(this._element._call), this._assertionMatcher._call.value, timeout / 1000);
|
52
60
|
await this.execute();
|
53
61
|
}
|
@@ -58,20 +66,18 @@ class WaitForInteraction extends Interaction {
|
|
58
66
|
}
|
59
67
|
|
60
68
|
class WaitForActionInteractionBase extends Interaction {
|
61
|
-
constructor(invocationManager, element, matcher, searchMatcher) {
|
62
|
-
super(invocationManager);
|
63
|
-
|
64
|
-
//if (!(matcher instanceof NativeMatcher)) throw new DetoxRuntimeError(`WaitForActionInteraction ctor 2nd argument must be a valid NativeMatcher, got ${typeof matcher}`);
|
69
|
+
constructor(invocationManager, element, matcher, searchMatcher, traceDescription) {
|
70
|
+
super(invocationManager, traceDescription);
|
71
|
+
|
65
72
|
if (!(searchMatcher instanceof NativeMatcher))
|
66
|
-
throw new DetoxRuntimeError(`WaitForActionInteraction ctor 3rd argument must be a valid NativeMatcher, got ${typeof searchMatcher}`);
|
73
|
+
throw new DetoxRuntimeError({ message: `WaitForActionInteraction ctor 3rd argument must be a valid NativeMatcher, got ${typeof searchMatcher}` });
|
74
|
+
|
67
75
|
this._element = element;
|
68
76
|
this._originalMatcher = matcher;
|
69
77
|
this._searchMatcher = searchMatcher;
|
70
78
|
}
|
71
79
|
|
72
80
|
_prepare(searchAction) {
|
73
|
-
//if (!searchAction instanceof Action) throw new DetoxRuntimeError(`WaitForActionInteraction _execute argument must be a valid Action, got ${typeof searchAction}`);
|
74
|
-
|
75
81
|
this._call = DetoxAssertionApi.waitForAssertMatcherWithSearchAction(
|
76
82
|
call(this._element._call),
|
77
83
|
call(this._originalMatcher._call).value,
|
@@ -83,6 +89,7 @@ class WaitForActionInteractionBase extends Interaction {
|
|
83
89
|
|
84
90
|
class WaitForActionInteraction extends WaitForActionInteractionBase {
|
85
91
|
async scroll(amount, direction = 'down', scrollPositionX, scrollPositionY) {
|
92
|
+
this._traceDescription = expectDescription.waitFor(actionDescription.scroll(amount, direction, scrollPositionX, scrollPositionY));
|
86
93
|
this._prepare(new ScrollAmountStopAtEdgeAction(direction, amount, scrollPositionX, scrollPositionY));
|
87
94
|
await this.execute();
|
88
95
|
}
|