detox 19.10.0 → 19.12.1-prerelease.0
Sign up to get free protection for your applications and to get access to all the features.
- package/Detox-android/com/wix/detox/{19.10.0/detox-19.10.0-javadoc.jar → 19.12.1-prerelease.0/detox-19.12.1-prerelease.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/19.12.1-prerelease.0/detox-19.12.1-prerelease.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/19.12.1-prerelease.0/detox-19.12.1-prerelease.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/19.12.1-prerelease.0/detox-19.12.1-prerelease.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/19.12.1-prerelease.0/detox-19.12.1-prerelease.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{19.10.0/detox-19.10.0-sources.jar → 19.12.1-prerelease.0/detox-19.12.1-prerelease.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/19.12.1-prerelease.0/detox-19.12.1-prerelease.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/19.12.1-prerelease.0/detox-19.12.1-prerelease.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/19.12.1-prerelease.0/detox-19.12.1-prerelease.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/19.12.1-prerelease.0/detox-19.12.1-prerelease.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/19.12.1-prerelease.0/detox-19.12.1-prerelease.0.aar +0 -0
- package/Detox-android/com/wix/detox/19.12.1-prerelease.0/detox-19.12.1-prerelease.0.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/19.12.1-prerelease.0/detox-19.12.1-prerelease.0.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/19.12.1-prerelease.0/detox-19.12.1-prerelease.0.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/19.12.1-prerelease.0/detox-19.12.1-prerelease.0.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{19.10.0/detox-19.10.0.pom → 19.12.1-prerelease.0/detox-19.12.1-prerelease.0.pom} +1 -7
- package/Detox-android/com/wix/detox/19.12.1-prerelease.0/detox-19.12.1-prerelease.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/19.12.1-prerelease.0/detox-19.12.1-prerelease.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/19.12.1-prerelease.0/detox-19.12.1-prerelease.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/19.12.1-prerelease.0/detox-19.12.1-prerelease.0.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/android/build.gradle +12 -6
- package/android/detox/build.gradle +13 -9
- package/android/detox/publishing.gradle +27 -27
- package/android/detox/src/full/java/com/wix/detox/LaunchArgs.java +9 -0
- 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/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/timers/DelegatedIdleInterrogationStrategySpec.kt +3 -11
- package/package.json +3 -3
- package/runners/jest-circus/listeners/DetoxCoreListener.js +24 -16
- package/src/DetoxExportWrapper.js +1 -1
- package/src/android/core/NativeElement.js +56 -20
- package/src/android/core/NativeExpect.js +28 -9
- package/src/android/interactions/native.js +24 -18
- package/src/artifacts/timeline/TimelineArtifactPlugin.js +6 -9
- package/src/artifacts/timeline/TimelineContextTypes.js +7 -0
- package/src/devices/allocation/DeviceAllocator.js +1 -2
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +1 -2
- package/src/devices/runtime/RuntimeDevice.js +7 -11
- package/src/ios/expectTwo.js +152 -67
- package/src/utils/invocationTraceDescriptions.js +43 -0
- package/src/utils/trace.js +52 -10
- package/Detox-android/com/wix/detox/19.10.0/detox-19.10.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.10.0/detox-19.10.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.10.0/detox-19.10.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.10.0/detox-19.10.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.10.0/detox-19.10.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.10.0/detox-19.10.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.10.0/detox-19.10.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.10.0/detox-19.10.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.10.0/detox-19.10.0.aar +0 -0
- package/Detox-android/com/wix/detox/19.10.0/detox-19.10.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.10.0/detox-19.10.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.10.0/detox-19.10.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.10.0/detox-19.10.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.10.0/detox-19.10.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/19.10.0/detox-19.10.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.10.0/detox-19.10.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.10.0/detox-19.10.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/src/ios/expectTwo.js
CHANGED
@@ -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 { traceInvocationCall } = 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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
202
|
+
const traceDescription = actionDescription.tapBackspaceKey();
|
203
|
+
return this.withAction('tapBackspaceKey', traceDescription);
|
180
204
|
}
|
181
205
|
|
182
206
|
tapReturnKey() {
|
183
|
-
|
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
|
-
|
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
|
-
|
220
|
+
|
221
|
+
const traceDescription = actionDescription.replaceText(text);
|
222
|
+
return this.withAction('replaceText', traceDescription, text);
|
194
223
|
}
|
195
224
|
|
196
225
|
clearText() {
|
197
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
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
|
350
|
+
return _executeInvocation(this._invocationManager, invocation, traceDescription);
|
298
351
|
}
|
299
352
|
}
|
300
353
|
|
301
354
|
class InternalElement extends Element {
|
302
|
-
|
303
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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 traceInvocationCall(traceDescription, invocation, invocationManager.execute(invocation));
|
751
|
+
}
|
752
|
+
|
668
753
|
module.exports = IosExpect;
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module.exports = {
|
2
|
+
actionDescription: {
|
3
|
+
adjustSliderToPosition: (newPosition) => `adjust slider to position ${newPosition}`,
|
4
|
+
clearText: () => 'clear input text',
|
5
|
+
getAttributes: () => 'get element attributes',
|
6
|
+
longPress: (duration) => `long press${duration !== undefined ? ` for ${duration}ms` : ''}`,
|
7
|
+
longPressAndDrag: (duration, startX, startY, targetElement, endX, endY, speed, holdDuration) =>
|
8
|
+
`long press and drag from ${startX}, ${startY} to ${endX}, ${endY} with speed ${speed} and hold duration ${holdDuration}`,
|
9
|
+
multiTap: (times) => `tap ${times} times`,
|
10
|
+
pinch: (scale, speed, angle) => `pinch with scale ${scale}, speed ${speed}, and angle ${angle}`,
|
11
|
+
pinchWithAngle: (direction, speed, angle) => `pinch with direction ${direction}, speed ${speed}, and angle ${angle}`,
|
12
|
+
replaceText: (value) => `replace input text: "${value}"`,
|
13
|
+
scroll: (amount, direction, startPositionX, startPositionY) =>
|
14
|
+
`scroll ${amount} pixels ${direction}${startPositionX !== undefined && startPositionY !== undefined ? ` from normalized position (${startPositionX}, ${startPositionY})` : ''}`,
|
15
|
+
scrollTo: (edge) => `scroll to ${edge}`,
|
16
|
+
scrollToIndex: (index) => `scroll to index #${index}`,
|
17
|
+
setColumnToValue: (column, value) => `set column ${column} to value ${value}`,
|
18
|
+
setDatePickerDate: (dateString, dateFormat) => `set date picker date to ${dateString} using format ${dateFormat}`,
|
19
|
+
swipe: (direction, speed, normalizedSwipeOffset, normalizedStartingPointX, normalizedStartingPointY) =>
|
20
|
+
`swipe ${direction} ${speed} with offset ${normalizedSwipeOffset}
|
21
|
+
${!isNaN(normalizedStartingPointX) && !isNaN(normalizedStartingPointY) ? ` from normalized position (${normalizedStartingPointX}, ${normalizedStartingPointY})` : ''}`,
|
22
|
+
takeScreenshot: (screenshotName) => `take screenshot${screenshotName !== undefined ? ` with name "${screenshotName}"` : ''}`,
|
23
|
+
tapAtPoint: (value) => `tap${value !== undefined ? ` at ${JSON.stringify(value)}` : ''}`,
|
24
|
+
tapBackspaceKey: () => 'tap on backspace key',
|
25
|
+
tapReturnKey: () => 'tap on return key',
|
26
|
+
typeText: (value) => `type input text: "${value}"`,
|
27
|
+
},
|
28
|
+
expectDescription: {
|
29
|
+
waitFor: (actionDescription) => `wait for expectation while ${actionDescription}`,
|
30
|
+
waitForWithTimeout: (expectDescription, timeout) => `${expectDescription} with timeout (${timeout} ms)`,
|
31
|
+
withTimeout: (timeout) => `wait until timeout (${timeout} ms)`,
|
32
|
+
toBeFocused: () => 'to be focused',
|
33
|
+
toBeVisible: (percent) => `to be visible${percent !== undefined ? ` ${percent}%` : ''}`,
|
34
|
+
toExist: () => 'to exist',
|
35
|
+
toHaveText: (text) => `to have text: "${text}"`,
|
36
|
+
toHaveLabel: (label) => `to have label: "${label}"`,
|
37
|
+
toHaveId: (id) => `to have id: "${id}"`,
|
38
|
+
toHaveValue: (value) => `to have value: "${value}"`,
|
39
|
+
toHaveSliderPosition: (position, tolerance) => `to have slider position: ${position}${tolerance > 0 ? ` with tolerance ${tolerance}` : ''}`,
|
40
|
+
toHaveToggleValue: (value) => `to have toggle value: ${value}`,
|
41
|
+
full: (expectDescription, notCondition) => `expect element ${notCondition ? `not ${expectDescription}` : expectDescription}`
|
42
|
+
}
|
43
|
+
};
|
package/src/utils/trace.js
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
const assert = require('assert');
|
2
|
+
|
3
|
+
const TIMELINE_CONTEXT_TYPES = require('../artifacts/timeline/TimelineContextTypes');
|
4
|
+
|
1
5
|
class Trace {
|
2
6
|
constructor() {
|
3
7
|
this.events = [];
|
@@ -35,20 +39,58 @@ class Trace {
|
|
35
39
|
}
|
36
40
|
|
37
41
|
let trace = new Trace();
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Trace a single call, with a given name and arguments.
|
45
|
+
* @param sectionName The name of the section to trace.
|
46
|
+
* @param promiseOrFunction {Promise|Function} Promise or a function that provides a promise.
|
47
|
+
* @param args {Object} Optional arguments to pass to the trace.
|
48
|
+
* @returns {any} The returned value of the traced call.
|
49
|
+
*
|
50
|
+
* @see https://wix.github.io/Detox/docs/next/api/detox-object-api/#detoxtracecall.
|
51
|
+
*/
|
52
|
+
function traceCall(sectionName, promiseOrFunction, args = {}) {
|
53
|
+
assert(sectionName,
|
54
|
+
`must provide section name when calling \`traceCall\` with args: \n ${JSON.stringify(args)}`);
|
55
|
+
|
56
|
+
const promise = typeof promiseOrFunction === 'function' ? promiseOrFunction() : promiseOrFunction;
|
57
|
+
|
58
|
+
trace.startSection(sectionName, args);
|
59
|
+
return promise
|
60
|
+
.then((result) => {
|
61
|
+
trace.endSection(sectionName, { ...args, success: true });
|
62
|
+
return result;
|
63
|
+
})
|
64
|
+
.catch((error) => {
|
65
|
+
trace.endSection(sectionName, { ...args, success: false, error: error.toString() });
|
66
|
+
throw error;
|
67
|
+
});
|
68
|
+
}
|
69
|
+
|
70
|
+
function traceInvocationCall(sectionName, invocation, promise) {
|
71
|
+
return traceCall(
|
72
|
+
sectionName, promise, {
|
73
|
+
context: TIMELINE_CONTEXT_TYPES.INVOCATION,
|
74
|
+
stackTrace: _getCallStackTrace(),
|
75
|
+
invocation: JSON.stringify(invocation),
|
76
|
+
});
|
77
|
+
}
|
78
|
+
|
79
|
+
function _getCallStackTrace() {
|
80
|
+
return new Error().stack
|
81
|
+
.split('\n')
|
82
|
+
.slice(1) // Ignore Error message
|
83
|
+
.map(line => line
|
84
|
+
.replace(/^\s*at\s+/, '')
|
85
|
+
.replace(process.cwd(), '')
|
86
|
+
)
|
87
|
+
.filter(line => !line.includes('/detox/src')) // Ignore detox internal calls
|
88
|
+
.join('\n');
|
48
89
|
}
|
49
90
|
|
50
91
|
module.exports = {
|
51
92
|
Trace,
|
52
93
|
trace,
|
53
94
|
traceCall,
|
95
|
+
traceInvocationCall
|
54
96
|
};
|
@@ -1 +0,0 @@
|
|
1
|
-
246e031bb8a10b4897c2f60868e38a1e
|
@@ -1 +0,0 @@
|
|
1
|
-
d6c2ec03684c08bf5d408feac4b3860de5a44d4b
|
@@ -1 +0,0 @@
|
|
1
|
-
55d164318e5c579b960d8db06251807668ea5efa1d51c8bf233d1caa6bd46239
|
@@ -1 +0,0 @@
|
|
1
|
-
0b02e740c3e40a3235be505b9dcb4918f26ede99694cbaf320d7234373918b418a22437232b39b78206a813593f725f5536471640401016e35fdb76b67ebac70
|
@@ -1 +0,0 @@
|
|
1
|
-
e52a3f44d369bd3f21cb7bb83d99dc33
|
@@ -1 +0,0 @@
|
|
1
|
-
9928c16835043133616631d4f76aad949aad2218
|
@@ -1 +0,0 @@
|
|
1
|
-
0b350d5a918515b94a07cb7ff736e3613e6ca5debfac16c60c7eb41d4625f26d
|
@@ -1 +0,0 @@
|
|
1
|
-
767e6cfec265b747dc3787d820abd9cf5713b40ce64420479348621faabb2f0f02f2cc83bf073d98ed5bc090e1abf9cabf86469b2bb3413fc413fe3764c90ffb
|