detox 20.0.5-breaking.new-global-lifecycle.0 → 20.0.8-prerelease.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. package/Detox-android/com/wix/detox/{20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-javadoc.jar → 20.0.8-prerelease.0/detox-20.0.8-prerelease.0-javadoc.jar} +0 -0
  2. package/Detox-android/com/wix/detox/20.0.8-prerelease.0/detox-20.0.8-prerelease.0-javadoc.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/20.0.8-prerelease.0/detox-20.0.8-prerelease.0-javadoc.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/20.0.8-prerelease.0/detox-20.0.8-prerelease.0-javadoc.jar.sha256 +1 -0
  5. package/Detox-android/com/wix/detox/20.0.8-prerelease.0/detox-20.0.8-prerelease.0-javadoc.jar.sha512 +1 -0
  6. package/Detox-android/com/wix/detox/{20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-sources.jar → 20.0.8-prerelease.0/detox-20.0.8-prerelease.0-sources.jar} +0 -0
  7. package/Detox-android/com/wix/detox/20.0.8-prerelease.0/detox-20.0.8-prerelease.0-sources.jar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/20.0.8-prerelease.0/detox-20.0.8-prerelease.0-sources.jar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/20.0.8-prerelease.0/detox-20.0.8-prerelease.0-sources.jar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/20.0.8-prerelease.0/detox-20.0.8-prerelease.0-sources.jar.sha512 +1 -0
  11. package/Detox-android/com/wix/detox/20.0.8-prerelease.0/detox-20.0.8-prerelease.0.aar +0 -0
  12. package/Detox-android/com/wix/detox/20.0.8-prerelease.0/detox-20.0.8-prerelease.0.aar.md5 +1 -0
  13. package/Detox-android/com/wix/detox/20.0.8-prerelease.0/detox-20.0.8-prerelease.0.aar.sha1 +1 -0
  14. package/Detox-android/com/wix/detox/20.0.8-prerelease.0/detox-20.0.8-prerelease.0.aar.sha256 +1 -0
  15. package/Detox-android/com/wix/detox/20.0.8-prerelease.0/detox-20.0.8-prerelease.0.aar.sha512 +1 -0
  16. package/Detox-android/com/wix/detox/{20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.pom → 20.0.8-prerelease.0/detox-20.0.8-prerelease.0.pom} +1 -7
  17. package/Detox-android/com/wix/detox/20.0.8-prerelease.0/detox-20.0.8-prerelease.0.pom.md5 +1 -0
  18. package/Detox-android/com/wix/detox/20.0.8-prerelease.0/detox-20.0.8-prerelease.0.pom.sha1 +1 -0
  19. package/Detox-android/com/wix/detox/20.0.8-prerelease.0/detox-20.0.8-prerelease.0.pom.sha256 +1 -0
  20. package/Detox-android/com/wix/detox/20.0.8-prerelease.0/detox-20.0.8-prerelease.0.pom.sha512 +1 -0
  21. package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
  22. package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
  23. package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
  24. package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
  25. package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
  26. package/Detox-ios-src.tbz +0 -0
  27. package/Detox-ios.tbz +0 -0
  28. package/android/build.gradle +12 -6
  29. package/android/detox/build.gradle +13 -9
  30. package/android/detox/proguard-rules-app.pro +4 -0
  31. package/android/detox/publishing.gradle +27 -27
  32. package/android/detox/src/full/java/com/wix/detox/DetoxCrashHandler.kt +1 -1
  33. package/android/detox/src/full/java/com/wix/detox/LaunchArgs.java +9 -0
  34. package/android/detox/src/full/java/com/wix/detox/TestEngineFacade.kt +1 -1
  35. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeExtension.kt +15 -2
  36. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeIdlingResources.kt +43 -38
  37. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategy.kt +7 -27
  38. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/IdleInterrogationStrategy.kt +1 -11
  39. package/android/detox/src/testFull/java/com/wix/detox/espresso/action/DetoxMultiTapSpec.kt +4 -3
  40. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategySpec.kt +3 -11
  41. package/index.d.ts +21 -1
  42. package/local-cli/test.js +9 -4
  43. package/local-cli/testCommand/TestRunnerCommand.js +8 -7
  44. package/package.json +3 -3
  45. package/runners/jest/testEnvironment/index.js +4 -3
  46. package/src/DetoxWorker.js +0 -6
  47. package/src/android/core/NativeElement.js +56 -20
  48. package/src/android/core/NativeExpect.js +28 -9
  49. package/src/android/interactions/native.js +24 -18
  50. package/src/artifacts/timeline/TimelineContextTypes.js +7 -0
  51. package/src/client/Client.js +18 -1
  52. package/src/configuration/composeRunnerConfig.js +1 -0
  53. package/src/devices/common/drivers/android/tools/MonitoredInstrumentation.js +1 -1
  54. package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +3 -1
  55. package/src/devices/runtime/RuntimeDevice.js +2 -4
  56. package/src/devices/runtime/drivers/android/AndroidDriver.js +9 -1
  57. package/src/ios/expectTwo.js +152 -67
  58. package/src/logger/DetoxLogger.js +21 -17
  59. package/src/logger/utils/tracerLegacy.js +24 -1
  60. package/src/realms/DetoxPrimaryContext.js +26 -11
  61. package/src/utils/errorUtils.js +4 -3
  62. package/src/utils/invocationTraceDescriptions.js +43 -0
  63. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-javadoc.jar.md5 +0 -1
  64. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +0 -1
  65. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +0 -1
  66. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +0 -1
  67. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-sources.jar.md5 +0 -1
  68. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-sources.jar.sha1 +0 -1
  69. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-sources.jar.sha256 +0 -1
  70. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-sources.jar.sha512 +0 -1
  71. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.aar +0 -0
  72. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.aar.md5 +0 -1
  73. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.aar.sha1 +0 -1
  74. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.aar.sha256 +0 -1
  75. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.aar.sha512 +0 -1
  76. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.pom.md5 +0 -1
  77. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.pom.sha1 +0 -1
  78. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.pom.sha256 +0 -1
  79. package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.pom.sha512 +0 -1
  80. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DefaultIdleInterrogationStrategy.kt +0 -84
  81. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DefaultIdleInterrogationStrategySpec.kt +0 -115
@@ -34,6 +34,7 @@ class Client {
34
34
  this._slowInvocationStatusHandle = null;
35
35
  this._whenAppIsConnected = this._invalidState('before connecting to the app');
36
36
  this._whenAppIsReady = this._whenAppIsConnected;
37
+ this._whenAppDisconnected = Deferred.resolved();
37
38
  this._isCleaningUp = false;
38
39
  this._pendingAppCrash = null;
39
40
  this._appTerminationHandle = null;
@@ -201,6 +202,11 @@ class Client {
201
202
  }
202
203
  }
203
204
 
205
+ /** @async */
206
+ waitUntilDisconnected() {
207
+ return this._whenAppDisconnected.promise;
208
+ }
209
+
204
210
  async waitForBackground() {
205
211
  await this.sendAction(new actions.WaitForBackground());
206
212
  }
@@ -301,6 +307,8 @@ class Client {
301
307
  } else {
302
308
  this._whenAppIsConnected = Deferred.resolved();
303
309
  }
310
+
311
+ this._whenAppDisconnected = new Deferred();
304
312
  }
305
313
 
306
314
  _onAppReady() {
@@ -320,6 +328,10 @@ class Client {
320
328
  }
321
329
 
322
330
  _onBeforeAppCrash({ params }) {
331
+ if (this._pendingAppCrash) {
332
+ return;
333
+ }
334
+
323
335
  this._pendingAppCrash = new DetoxRuntimeError({
324
336
  message: 'The app has crashed, see the details below:',
325
337
  debugInfo: params.errorDetails,
@@ -338,10 +350,15 @@ class Client {
338
350
  this._whenAppIsReady = this._whenAppIsConnected;
339
351
 
340
352
  if (this._pendingAppCrash) {
353
+ this._whenAppDisconnected.reject(this._pendingAppCrash);
341
354
  this._asyncWebSocket.rejectAll(this._pendingAppCrash);
342
355
  this._pendingAppCrash = null;
343
356
  } else if (this._asyncWebSocket.hasPendingActions()) {
344
- this._asyncWebSocket.rejectAll(new DetoxRuntimeError('The app has unexpectedly disconnected from Detox server.'));
357
+ const error = new DetoxRuntimeError('The app has unexpectedly disconnected from Detox server.');
358
+ this._asyncWebSocket.rejectAll(error);
359
+ this._whenAppDisconnected.resolve();
360
+ } else {
361
+ this._whenAppDisconnected.resolve();
345
362
  }
346
363
  }
347
364
 
@@ -31,6 +31,7 @@ function composeRunnerConfig(opts) {
31
31
  {
32
32
  retries: 0,
33
33
  inspectBrk: inspectBrkHookDefault,
34
+ forwardEnv: false,
34
35
  jest: {
35
36
  initTimeout: 300000,
36
37
  retryAfterCircusRetries: false,
@@ -77,7 +77,7 @@ class MonitoredInstrumentation {
77
77
  'while it was waiting for "ready" message (over WebSocket) ' +
78
78
  'from the instrumentation process.',
79
79
  debugInfo: this.instrumentationStackTrace
80
- ? `Native stacktrace dump: ${this.instrumentationStackTrace}`
80
+ ? `Native stacktrace dump:\n${this.instrumentationStackTrace}`
81
81
  : '',
82
82
  });
83
83
  }
@@ -271,7 +271,9 @@ class AppleSimUtils {
271
271
  // ```
272
272
  // This workaround is done to ignore the error above, as we do not care if the app was running before, we just
273
273
  // want to make sure it isn't now.
274
- if (err.code === 3 && err.stderr.includes(`the app is not currently running`)) {
274
+ if (err.code === 3 &&
275
+ (err.stderr.includes(`the app is not currently running`) ||
276
+ err.stderr.includes(`The operation couldn’t be completed. found nothing to terminate`))) {
275
277
  return;
276
278
  }
277
279
 
@@ -248,14 +248,12 @@ class RuntimeDevice {
248
248
  async installUtilBinaries() {
249
249
  const paths = this._deviceConfig.utilBinaryPaths;
250
250
  if (paths) {
251
- await traceCall('installUtilBinaries', () =>
252
- this.deviceDriver.installUtilBinaries(paths));
251
+ await traceCall('installUtilBinaries', this.deviceDriver.installUtilBinaries(paths));
253
252
  }
254
253
  }
255
254
 
256
255
  async reloadReactNative() {
257
- await traceCall('reloadRN', () =>
258
- this.deviceDriver.reloadReactNative());
256
+ await traceCall('reload React Native', this.deviceDriver.reloadReactNative());
259
257
  }
260
258
 
261
259
  async openURL(params) {
@@ -148,7 +148,15 @@ class AndroidDriver extends DeviceDriverBase {
148
148
 
149
149
  async waitUntilReady() {
150
150
  try {
151
- await Promise.race([super.waitUntilReady(), this.instrumentation.waitForCrash()]);
151
+ await Promise.race([
152
+ super.waitUntilReady(),
153
+ this.instrumentation.waitForCrash()
154
+ ]);
155
+ } catch (e) {
156
+ log.warn({ error: e }, 'An error occurred while waiting for the app to become ready. Waiting for disconnection...');
157
+ await this.client.waitUntilDisconnected();
158
+ log.warn('The app disconnected.');
159
+ throw e;
152
160
  } finally {
153
161
  this.instrumentation.abortWaitForCrash();
154
162
  }
@@ -1,4 +1,5 @@
1
1
  // @ts-nocheck
2
+ const assert = require('assert');
2
3
  const path = require('path');
3
4
 
4
5
  const fs = require('fs-extra');
@@ -6,6 +7,8 @@ const _ = require('lodash');
6
7
  const tempfile = require('tempfile');
7
8
 
8
9
  const { assertEnum, assertNormalized } = require('../utils/assertArgument');
10
+ const { actionDescription, expectDescription } = require('../utils/invocationTraceDescriptions');
11
+ const { trace } = require('../utils/trace');
9
12
 
10
13
  const assertDirection = assertEnum(['left', 'right', 'up', 'down']);
11
14
  const assertSpeed = assertEnum(['fast', 'slow']);
@@ -23,7 +26,8 @@ class Expect {
23
26
  + (percent + (' (' + (typeof percent + ')'))));
24
27
  }
25
28
 
26
- return this.expect('toBeVisible', percent);
29
+ const traceDescription = expectDescription.toBeVisible(percent);
30
+ return this.expect('toBeVisible', traceDescription, percent);
27
31
  }
28
32
 
29
33
  toBeNotVisible() {
@@ -31,7 +35,8 @@ class Expect {
31
35
  }
32
36
 
33
37
  toBeFocused() {
34
- return this.expect('toBeFocused');
38
+ const traceDescription = expectDescription.toBeFocused();
39
+ return this.expect('toBeFocused', traceDescription);
35
40
  }
36
41
 
37
42
  toBeNotFocused() {
@@ -39,7 +44,8 @@ class Expect {
39
44
  }
40
45
 
41
46
  toExist() {
42
- return this.expect('toExist');
47
+ const traceDescription = expectDescription.toExist();
48
+ return this.expect('toExist', traceDescription);
43
49
  }
44
50
 
45
51
  toNotExist() {
@@ -47,7 +53,8 @@ class Expect {
47
53
  }
48
54
 
49
55
  toHaveText(text) {
50
- return this.expect('toHaveText', text);
56
+ const traceDescription = expectDescription.toHaveText(text);
57
+ return this.expect('toHaveText', traceDescription, text);
51
58
  }
52
59
 
53
60
  toNotHaveText(text) {
@@ -55,7 +62,8 @@ class Expect {
55
62
  }
56
63
 
57
64
  toHaveLabel(label) {
58
- return this.expect('toHaveLabel', label);
65
+ const traceDescription = expectDescription.toHaveLabel(label);
66
+ return this.expect('toHaveLabel', traceDescription, label);
59
67
  }
60
68
 
61
69
  toNotHaveLabel(label) {
@@ -63,7 +71,8 @@ class Expect {
63
71
  }
64
72
 
65
73
  toHaveId(id) {
66
- return this.expect('toHaveId', id);
74
+ const traceDescription = expectDescription.toHaveId(id);
75
+ return this.expect('toHaveId', traceDescription, id);
67
76
  }
68
77
 
69
78
  toNotHaveId(id) {
@@ -71,7 +80,8 @@ class Expect {
71
80
  }
72
81
 
73
82
  toHaveValue(value) {
74
- return this.expect('toHaveValue', value);
83
+ const traceDescription = expectDescription.toHaveValue(value);
84
+ return this.expect('toHaveValue', traceDescription, value);
75
85
  }
76
86
 
77
87
  toNotHaveValue(value) {
@@ -79,7 +89,8 @@ class Expect {
79
89
  }
80
90
 
81
91
  toHaveSliderPosition(position, tolerance = 0) {
82
- return this.expect('toHaveSliderPosition', position, tolerance);
92
+ const traceDescription = expectDescription.toHaveSliderPosition(position, tolerance);
93
+ return this.expect('toHaveSliderPosition', traceDescription, position, tolerance);
83
94
  }
84
95
 
85
96
  toHaveToggleValue(value) {
@@ -103,16 +114,18 @@ class Expect {
103
114
  };
104
115
  }
105
116
 
106
- expect(expectation, ...params) {
117
+ expect(expectation, traceDescription, ...params) {
118
+ assert(traceDescription, `must provide trace description for expectation: \n ${JSON.stringify(expectation)}`);
119
+
107
120
  const invocation = this.createInvocation(expectation, ...params);
108
- return this._invocationManager.execute(invocation);
121
+ traceDescription = expectDescription.full(traceDescription, this.modifiers.includes('not'));
122
+ return _executeInvocation(this._invocationManager, invocation, traceDescription);
109
123
  }
110
124
  }
111
125
 
112
126
  class InternalExpect extends Expect {
113
- expect(expectation, ...params) {
114
- const invocation = this.createInvocation(expectation, ...params);
115
- return invocation;
127
+ expect(expectation, _traceDescription, ...params) {
128
+ return this.createInvocation(expectation, ...params);
116
129
  }
117
130
  }
118
131
 
@@ -131,7 +144,8 @@ class Element {
131
144
  }
132
145
 
133
146
  getAttributes() {
134
- return this.withAction('getAttributes');
147
+ const traceDescription = actionDescription.getAttributes();
148
+ return this.withAction('getAttributes', traceDescription);
135
149
  }
136
150
 
137
151
  tap(point) {
@@ -140,12 +154,16 @@ class Element {
140
154
  if (typeof point.x !== 'number') throw new Error('point.x should be a number, but got ' + (point.x + (' (' + (typeof point.x + ')'))));
141
155
  if (typeof point.y !== 'number') throw new Error('point.y should be a number, but got ' + (point.y + (' (' + (typeof point.y + ')'))));
142
156
  }
143
- return this.withAction('tap', point);
157
+
158
+ const traceDescription = actionDescription.tapAtPoint(point);
159
+ return this.withAction('tap', traceDescription, point);
144
160
  }
145
161
 
146
162
  longPress(duration = 1000) {
147
163
  if (typeof duration !== 'number') throw new Error('duration should be a number, but got ' + (duration + (' (' + (typeof duration + ')'))));
148
- return this.withAction('longPress', duration);
164
+
165
+ const traceDescription = actionDescription.longPress(duration);
166
+ return this.withAction('longPress', traceDescription, duration);
149
167
  }
150
168
 
151
169
  longPressAndDrag(duration, normalizedPositionX, normalizedPositionY, targetElement,
@@ -162,13 +180,18 @@ class Element {
162
180
  assertNormalized({ normalizedTargetPositionX });
163
181
  assertNormalized({ normalizedTargetPositionY });
164
182
 
165
- return this.withActionAndTargetElement('longPress', targetElement, duration, normalizedPositionX, normalizedPositionY,
183
+ const traceDescription = actionDescription.longPressAndDrag(duration, normalizedPositionX, normalizedPositionY, targetElement,
184
+ normalizedTargetPositionX, normalizedTargetPositionY, speed, holdDuration);
185
+ return this.withActionAndTargetElement('longPress', targetElement, traceDescription, duration, normalizedPositionX, normalizedPositionY,
166
186
  normalizedTargetPositionX, normalizedTargetPositionY, speed, holdDuration);
167
187
  }
168
188
 
169
189
  multiTap(times) {
170
190
  if (typeof times !== 'number') throw new Error('times should be a number, but got ' + (times + (' (' + (typeof times + ')'))));
171
- return this.withAction('multiTap', times);
191
+ if (times < 1) throw new Error('times should be greater than 0, but got ' + times);
192
+
193
+ const traceDescription = actionDescription.multiTap(times);
194
+ return this.withAction('multiTap', traceDescription, times);
172
195
  }
173
196
 
174
197
  tapAtPoint(point) {
@@ -176,25 +199,32 @@ class Element {
176
199
  }
177
200
 
178
201
  tapBackspaceKey() {
179
- return this.withAction('tapBackspaceKey');
202
+ const traceDescription = actionDescription.tapBackspaceKey();
203
+ return this.withAction('tapBackspaceKey', traceDescription);
180
204
  }
181
205
 
182
206
  tapReturnKey() {
183
- return this.withAction('tapReturnKey');
207
+ const traceDescription = actionDescription.tapReturnKey();
208
+ return this.withAction('tapReturnKey', traceDescription);
184
209
  }
185
210
 
186
211
  typeText(text) {
187
212
  if (typeof text !== 'string') throw new Error('text should be a string, but got ' + (text + (' (' + (typeof text + ')'))));
188
- return this.withAction('typeText', text);
213
+
214
+ const traceDescription = actionDescription.typeText(text);
215
+ return this.withAction('typeText', traceDescription, text);
189
216
  }
190
217
 
191
218
  replaceText(text) {
192
219
  if (typeof text !== 'string') throw new Error('text should be a string, but got ' + (text + (' (' + (typeof text + ')'))));
193
- return this.withAction('replaceText', text);
220
+
221
+ const traceDescription = actionDescription.replaceText(text);
222
+ return this.withAction('replaceText', traceDescription, text);
194
223
  }
195
224
 
196
225
  clearText() {
197
- return this.withAction('clearText');
226
+ const traceDescription = actionDescription.clearText();
227
+ return this.withAction('clearText', traceDescription);
198
228
  }
199
229
 
200
230
  scroll(pixels, direction = 'down', startPositionX = NaN, startPositionY = NaN) {
@@ -202,12 +232,15 @@ class Element {
202
232
  if (typeof pixels !== 'number') throw new Error('amount of pixels should be a number, but got ' + (pixels + (' (' + (typeof pixels + ')'))));
203
233
  if (typeof startPositionX !== 'number') throw new Error('startPositionX should be a number, but got ' + (startPositionX + (' (' + (typeof startPositionX + ')'))));
204
234
  if (typeof startPositionY !== 'number') throw new Error('startPositionY should be a number, but got ' + (startPositionY + (' (' + (typeof startPositionY + ')'))));
205
- return this.withAction('scroll', pixels, direction, startPositionX, startPositionY);
235
+
236
+ const traceDescription = actionDescription.scroll(pixels, direction, startPositionX, startPositionY);
237
+ return this.withAction('scroll', traceDescription, pixels, direction, startPositionX, startPositionY);
206
238
  }
207
239
 
208
240
  scrollTo(edge) {
209
241
  if (!['left', 'right', 'top', 'bottom'].some(option => option === edge)) throw new Error('edge should be one of [left, right, top, bottom], but got ' + edge);
210
- return this.withAction('scrollTo', edge);
242
+ const traceDescription = actionDescription.scrollTo(edge);
243
+ return this.withAction('scrollTo', traceDescription, edge);
211
244
  }
212
245
 
213
246
  swipe(direction, speed = 'fast', normalizedSwipeOffset = NaN, normalizedStartingPointX = NaN, normalizedStartingPointY = NaN) {
@@ -218,42 +251,62 @@ class Element {
218
251
  assertNormalized({ normalizedStartingPointY });
219
252
 
220
253
  normalizedSwipeOffset = Number.isNaN(normalizedSwipeOffset) ? 0.75 : normalizedSwipeOffset;
221
- return this.withAction('swipe', direction, speed, normalizedSwipeOffset, normalizedStartingPointX, normalizedStartingPointY);
254
+ const traceDescription = actionDescription.swipe(direction, speed, normalizedSwipeOffset, normalizedStartingPointX, normalizedStartingPointY);
255
+ return this.withAction(
256
+ 'swipe',
257
+ traceDescription,
258
+ direction,
259
+ speed,
260
+ normalizedSwipeOffset,
261
+ normalizedStartingPointX,
262
+ normalizedStartingPointY
263
+ );
222
264
  }
223
265
 
224
266
  setColumnToValue(column, value) {
225
267
  if (typeof column !== 'number') throw new Error('column should be a number, but got ' + (column + (' (' + (typeof column + ')'))));
226
268
  if (typeof value !== 'string') throw new Error('value should be a string, but got ' + (value + (' (' + (typeof value + ')'))));
227
- return this.withAction('setColumnToValue', column, value);
269
+
270
+ const traceDescription = actionDescription.setColumnToValue(column, value);
271
+ return this.withAction('setColumnToValue', traceDescription, column, value);
228
272
  }
229
273
 
230
274
  setDatePickerDate(dateString, dateFormat) {
231
275
  if (typeof dateString !== 'string') throw new Error('dateString should be a string, but got ' + (dateString + (' (' + (typeof dateString + ')'))));
232
276
  if (typeof dateFormat !== 'string') throw new Error('dateFormat should be a string, but got ' + (dateFormat + (' (' + (typeof dateFormat + ')'))));
233
- return this.withAction('setDatePickerDate', dateString, dateFormat);
277
+
278
+ const traceDescription = actionDescription.setDatePickerDate(dateString, dateFormat);
279
+ return this.withAction('setDatePickerDate', traceDescription, dateString, dateFormat);
234
280
  }
235
281
 
236
282
  pinch(scale, speed = 'fast', angle = 0) {
237
283
  if (typeof scale !== 'number' || !Number.isFinite(scale) || scale < 0) throw new Error(`pinch scale must be a finite number larger than zero`);
238
284
  if (!['slow', 'fast'].includes(speed)) throw new Error(`pinch speed is either 'slow' or 'fast'`);
239
285
  if (typeof angle !== 'number' || !Number.isFinite(angle)) throw new Error(`pinch angle must be a finite number (radian)`);
240
- return this.withAction('pinch', scale, speed, angle);
286
+
287
+ const traceDescription = actionDescription.pinch(scale, speed, angle);
288
+ return this.withAction('pinch', traceDescription, scale, speed, angle);
241
289
  }
242
290
 
243
291
  pinchWithAngle(direction, speed = 'slow', angle = 0) {
244
292
  if (!['inward', 'outward'].includes(direction)) throw new Error(`pinchWithAngle direction is either 'inward' or 'outward'`);
245
293
  if (!['slow', 'fast'].includes(speed)) throw new Error(`pinchWithAngle speed is either 'slow' or 'fast'`);
246
294
  if (typeof angle !== 'number') throw new Error(`pinchWithAngle angle must be a number (radiant), got ${typeof angle}`);
247
- return this.withAction('pinchWithAngle', direction, speed, angle);
295
+
296
+ const traceDescription = actionDescription.pinchWithAngle(direction, speed, angle);
297
+ return this.withAction('pinchWithAngle', traceDescription, direction, speed, angle);
248
298
  }
249
299
 
250
300
  adjustSliderToPosition(position) {
251
301
  if (!(typeof position === 'number' && position >= 0 && position <= 1)) throw new Error('position should be a number [0.0, 1.0], but got ' + (position + (' (' + (typeof position + ')'))));
252
- return this.withAction('adjustSliderToPosition', position);
302
+
303
+ const traceDescription = actionDescription.adjustSliderToPosition(position);
304
+ return this.withAction('adjustSliderToPosition', traceDescription, position);
253
305
  }
254
306
 
255
307
  async takeScreenshot(fileName) {
256
- const { screenshotPath } = await this.withAction('takeScreenshot', fileName);
308
+ const traceDescription = actionDescription.takeScreenshot(fileName);
309
+ const { screenshotPath } = await this.withAction('takeScreenshot', traceDescription, fileName);
257
310
 
258
311
  const filePath = tempfile('.detox.element-screenshot.png');
259
312
  await fs.move(screenshotPath, filePath);
@@ -287,22 +340,20 @@ class Element {
287
340
  return invocation;
288
341
  }
289
342
 
290
- withAction(action, ...params) {
343
+ withAction(action, traceDescription, ...params) {
291
344
  const invocation = this.createInvocation(action, null, ...params);
292
- return this._invocationManager.execute(invocation);
345
+ return _executeInvocation(this._invocationManager, invocation, traceDescription);
293
346
  }
294
347
 
295
- withActionAndTargetElement(action, targetElement, ...params) {
348
+ withActionAndTargetElement(action, targetElement, traceDescription, ...params) {
296
349
  const invocation = this.createInvocation(action, targetElement, ...params);
297
- return this._invocationManager.execute(invocation);
350
+ return _executeInvocation(this._invocationManager, invocation, traceDescription);
298
351
  }
299
352
  }
300
353
 
301
354
  class InternalElement extends Element {
302
-
303
- withAction(action, ...params) {
304
- const invocation = this.createInvocation(action, null, ...params);
305
- return invocation;
355
+ withAction(action, _traceDescription, ...params) {
356
+ return this.createInvocation(action, null, ...params);
306
357
  }
307
358
  }
308
359
 
@@ -341,7 +392,6 @@ class By {
341
392
  }
342
393
 
343
394
  class Matcher {
344
-
345
395
  accessibilityLabel(label) {
346
396
  return this.label(label);
347
397
  }
@@ -395,14 +445,12 @@ class Matcher {
395
445
  if (!(matcher instanceof Matcher)) {
396
446
  throwMatcherError(matcher);
397
447
  }
448
+
398
449
  this.and({ predicate: { type: 'descendant', predicate: matcher.predicate } });
399
450
  return this;
400
451
  }
401
452
 
402
453
  and(matcher) {
403
- // if (!(matcher instanceof Matcher)) {
404
- // throwMatcherError(matcher);
405
- // }
406
454
  const tempPredicate = this.predicate;
407
455
  delete this.predicate;
408
456
  this.predicate = { type: 'and', predicates: [] };
@@ -493,7 +541,9 @@ class WaitFor {
493
541
  if (typeof timeout !== 'number') throw new Error('text should be a number, but got ' + (timeout + (' (' + (typeof timeout + ')'))));
494
542
  if (timeout < 0) throw new Error('timeout must be larger than 0');
495
543
  this.timeout = timeout;
496
- return this.waitForWithTimeout();
544
+
545
+ const traceDescription = expectDescription.withTimeout(timeout);
546
+ return this.waitForWithTimeout(traceDescription);
497
547
  }
498
548
 
499
549
  whileElement(matcher) {
@@ -504,106 +554,137 @@ class WaitFor {
504
554
 
505
555
  tap(point) {
506
556
  this.action = this.actionableElement.tap(point);
507
- return this.waitForWithAction();
557
+ const traceDescription = actionDescription.tapAtPoint(point);
558
+ return this.waitForWithAction(traceDescription);
508
559
  }
509
560
 
510
561
  longPress(duration) {
511
562
  this.action = this.actionableElement.longPress(duration);
512
- return this.waitForWithAction();
563
+ const traceDescription = actionDescription.longPress(duration);
564
+ return this.waitForWithAction(traceDescription);
513
565
  }
514
566
 
515
567
  multiTap(times) {
516
568
  this.action = this.actionableElement.multiTap(times);
517
- return this.waitForWithAction();
569
+ const traceDescription = actionDescription.multiTap(times);
570
+ return this.waitForWithAction(traceDescription);
518
571
  }
519
572
 
520
573
  tapAtPoint(point) {
521
574
  this.action = this.actionableElement.tap(point);
522
- return this.waitForWithAction();
575
+ const traceDescription = actionDescription.tapAtPoint(point);
576
+ return this.waitForWithAction(traceDescription);
523
577
  }
524
578
 
525
579
  tapBackspaceKey() {
526
580
  this.action = this.actionableElement.tapBackspaceKey();
527
- return this.waitForWithAction();
581
+ const traceDescription = actionDescription.tapBackspaceKey();
582
+ return this.waitForWithAction(traceDescription);
528
583
  }
529
584
 
530
585
  tapReturnKey() {
531
586
  this.action = this.actionableElement.tapReturnKey();
532
- return this.waitForWithAction();
587
+ const traceDescription = actionDescription.tapReturnKey();
588
+ return this.waitForWithAction(traceDescription);
533
589
  }
534
590
 
535
591
  typeText(text) {
536
592
  this.action = this.actionableElement.typeText(text);
537
- return this.waitForWithAction();
593
+ const traceDescription = actionDescription.typeText(text);
594
+ return this.waitForWithAction(traceDescription);
538
595
  }
539
596
 
540
597
  replaceText(text) {
541
598
  this.action = this.actionableElement.replaceText(text);
542
- return this.waitForWithAction();
599
+ const traceDescription = actionDescription.replaceText(text);
600
+ return this.waitForWithAction(traceDescription);
543
601
  }
544
602
 
545
603
  clearText() {
546
604
  this.action = this.actionableElement.clearText();
547
- return this.waitForWithAction();
605
+ const traceDescription = actionDescription.clearText();
606
+ return this.waitForWithAction(traceDescription);
548
607
  }
549
608
 
550
609
  scroll(pixels, direction, startPositionX, startPositionY) {
551
610
  this.action = this.actionableElement.scroll(pixels, direction, startPositionX, startPositionY);
552
- return this.waitForWithAction();
611
+
612
+ const traceDescription = actionDescription.scroll(pixels, direction, startPositionX, startPositionY);
613
+ return this.waitForWithAction(traceDescription);
553
614
  }
554
615
 
555
616
  scrollTo(edge) {
556
617
  this.action = this.actionableElement.scrollTo(edge);
557
- return this.waitForWithAction();
618
+ const traceDescription = actionDescription.scrollTo(edge);
619
+ return this.waitForWithAction(traceDescription);
558
620
  }
559
621
 
560
622
  swipe(direction, speed, percentage) {
561
623
  this.action = this.actionableElement.swipe(direction, speed, percentage);
562
- return this.waitForWithAction();
624
+ const traceDescription = actionDescription.swipe(direction, speed, percentage);
625
+ return this.waitForWithAction(traceDescription);
563
626
  }
564
627
 
565
628
  setColumnToValue(column, value) {
566
629
  this.action = this.actionableElement.setColumnToValue(column, value);
567
- return this.waitForWithAction();
630
+ const traceDescription = actionDescription.setColumnToValue(column, value);
631
+ return this.waitForWithAction(traceDescription);
568
632
  }
569
633
 
570
634
  setDatePickerDate(dateString, dateFormat) {
571
635
  this.action = this.actionableElement.setDatePickerDate(dateString, dateFormat);
572
- return this.waitForWithAction();
636
+ const traceDescription = actionDescription.setDatePickerDate(dateString, dateFormat);
637
+ return this.waitForWithAction(traceDescription);
573
638
  }
574
639
 
575
640
  pinch(scale, speed, angle) {
576
641
  this.action = this.actionableElement.pinch(scale, speed, angle);
577
- return this.waitForWithAction();
642
+ const traceDescription = actionDescription.pinch(scale, speed, angle);
643
+ return this.waitForWithAction(traceDescription);
578
644
  }
579
645
 
580
646
  pinchWithAngle(direction, speed, angle) {
581
647
  this.action = this.actionableElement.pinchWithAngle(direction, speed, angle);
582
- return this.waitForWithAction();
648
+ const traceDescription = actionDescription.pinchWithAngle(direction, speed, angle);
649
+ return this.waitForWithAction(traceDescription);
583
650
  }
584
651
 
585
- waitForWithAction() {
652
+ waitForWithAction(actionTraceDescription) {
586
653
  const expectation = this.expectation;
587
654
  const action = this.action;
588
655
 
589
- return this._invocationManager.execute({
656
+ const invocation = this.createWaitForWithActionInvocation(expectation, action);
657
+
658
+ const traceDescription = expectDescription.waitFor(actionTraceDescription);
659
+ return _executeInvocation(this._invocationManager, invocation, traceDescription);
660
+ }
661
+
662
+ createWaitForWithActionInvocation(expectation, action) {
663
+ return {
590
664
  ...action,
591
665
  while: {
592
666
  ...expectation
593
667
  }
594
- });
668
+ };
595
669
  }
596
670
 
597
- waitForWithTimeout() {
671
+ waitForWithTimeout(expectTraceDescription) {
598
672
  const expectation = this.expectation;
599
673
  const action = this.action;
600
674
  const timeout = this.timeout;
601
675
 
602
- return this._invocationManager.execute({
676
+ const invocation = this.createWaitForWithTimeoutInvocation(expectation, action, timeout);
677
+
678
+ const traceDescription = expectDescription.waitForWithTimeout(expectTraceDescription, timeout);
679
+ return _executeInvocation(this._invocationManager, invocation, traceDescription);
680
+ }
681
+
682
+ createWaitForWithTimeoutInvocation(expectation, action, timeout) {
683
+ return {
603
684
  ...action,
604
685
  ...expectation,
605
686
  timeout
606
- });
687
+ };
607
688
  }
608
689
  }
609
690
 
@@ -665,4 +746,8 @@ function throwElementError(param) {
665
746
  throw new Error(`${param} is not a Detox element. More about Detox elements here: https://wix.github.io/Detox/docs/api/matchers`);
666
747
  }
667
748
 
749
+ function _executeInvocation(invocationManager, invocation, traceDescription) {
750
+ return trace.invocationCall(traceDescription, invocation, invocationManager.execute(invocation));
751
+ }
752
+
668
753
  module.exports = IosExpect;