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
@@ -1,6 +1,5 @@
1
1
  package com.wix.detox.reactnative.idlingresources.timers
2
2
 
3
- import android.util.Log
4
3
  import com.facebook.react.bridge.ReactContext
5
4
  import com.wix.detox.common.UIThread
6
5
  import java.util.concurrent.Callable
@@ -13,14 +12,5 @@ fun getInterrogationStrategy(reactContext: ReactContext): IdleInterrogationStrat
13
12
  // Getting a native-module (inside) also initializes it if needed. That has to run on a
14
13
  // looper thread, and the easiest to make sure that happens is to use the main thread.
15
14
  UIThread.runSync(Callable {
16
- DelegatedIdleInterrogationStrategy.createIfSupported(reactContext)?.let {
17
- return@Callable it
18
- }
19
-
20
- DefaultIdleInterrogationStrategy.createIfSupported(reactContext)?.let {
21
- return@Callable it
22
- }
23
-
24
- Log.e(TimersIdlingResource.LOG_TAG, "Failed to determine proper implementation-strategy for timers idling resource")
25
- null
15
+ return@Callable DelegatedIdleInterrogationStrategy.create(reactContext)
26
16
  })
@@ -11,6 +11,7 @@ import org.assertj.core.api.Assertions.assertThat
11
11
  import org.mockito.kotlin.*
12
12
  import org.spekframework.spek2.Spek
13
13
  import org.spekframework.spek2.style.specification.describe
14
+ import java.lang.NullPointerException
14
15
  import kotlin.test.assertFailsWith
15
16
 
16
17
  object DetoxMultiTapSpec: Spek({
@@ -136,17 +137,17 @@ object DetoxMultiTapSpec: Spek({
136
137
  }
137
138
 
138
139
  it("should throw if no UI-controller provided") {
139
- assertFailsWith(KotlinNullPointerException::class) {
140
+ assertFailsWith(NullPointerException::class) {
140
141
  uut(1).sendTap(null, coordinates, precision, -1, -1)
141
142
  }
142
143
  }
143
144
 
144
145
  it("should throw if no coordinates / precision are provided") {
145
- assertFailsWith(KotlinNullPointerException::class) {
146
+ assertFailsWith(NullPointerException::class) {
146
147
  uut(1).sendTap(uiController, null, precision, -1, -1)
147
148
  }
148
149
 
149
- assertFailsWith(KotlinNullPointerException::class) {
150
+ assertFailsWith(NullPointerException::class) {
150
151
  uut(1).sendTap(uiController, coordinates, null, -1, -1)
151
152
  }
152
153
  }
@@ -5,22 +5,14 @@ import org.assertj.core.api.Assertions.assertThat
5
5
  import org.mockito.kotlin.*
6
6
  import org.spekframework.spek2.Spek
7
7
  import org.spekframework.spek2.style.specification.describe
8
+ import com.facebook.react.modules.core.TimingModule
8
9
 
9
10
  private const val BUSY_INTERVAL_MS = 1500L
10
11
 
11
- abstract class TimingModuleStub: NativeModule {
12
- abstract fun hasActiveTimersInRange(rangeMs: Long): Boolean
13
-
14
- override fun onCatalystInstanceDestroy() {}
15
- override fun getName(): String = "TimersNativeModuleStub"
16
- override fun canOverrideExistingModule() = false
17
- override fun initialize() {}
18
- }
19
-
20
12
  object DelegatedIdleInterrogationStrategySpec : Spek({
21
- describe("RN62+ timers idle-interrogation strategy") {
13
+ describe("Timers idle-interrogation strategy") {
22
14
 
23
- lateinit var timingModule: TimingModuleStub
15
+ lateinit var timingModule: TimingModule
24
16
 
25
17
  beforeEachTest {
26
18
  timingModule = mock()
package/index.d.ts CHANGED
@@ -157,6 +157,17 @@ declare global {
157
157
  * Use it when you rely on another test runner than Jest.
158
158
  */
159
159
  inspectBrk?: boolean | ((config: DetoxTestRunnerConfig) => void);
160
+ /**
161
+ * Forward environment variables to the spawned test runner
162
+ * accordingly to the given CLI argument overrides.
163
+ *
164
+ * If false, Detox CLI will be only printing a hint message on
165
+ * how to start the test runner using environment variables,
166
+ * in case when a user wants to avoid using Detox CLI.
167
+ *
168
+ * @default false
169
+ */
170
+ forwardEnv?: boolean;
160
171
  }
161
172
 
162
173
  type DetoxAppConfig = (DetoxBuiltInAppConfig | DetoxCustomAppConfig) & {
@@ -353,12 +364,21 @@ declare global {
353
364
  readonly startSection: (name: string) => void;
354
365
  /** @deprecated */
355
366
  readonly endSection: (name: string) => void;
367
+ /** @private */
368
+ readonly invocationCall: (...args: unknown[]) => unknown;
356
369
  };
357
370
 
358
371
  /**
372
+ * Trace a single call, with a given name and arguments.
373
+ *
359
374
  * @deprecated
375
+ * @param sectionName The name of the section to trace.
376
+ * @param promiseOrFunction Promise or a function that provides a promise.
377
+ * @param args Optional arguments to pass to the trace.
378
+ * @returns The returned value of the traced call.
379
+ * @see https://wix.github.io/Detox/docs/next/api/detox-object-api/#detoxtracecall.
360
380
  */
361
- readonly traceCall: <T>(event: string, action: () => Promise<T>) => Promise<T>;
381
+ readonly traceCall: <T>(event: string, action: () => Promise<T>, args?: Record<string, unknown>) => Promise<T>;
362
382
  }
363
383
 
364
384
  interface Logger {
package/local-cli/test.js CHANGED
@@ -9,16 +9,21 @@ module.exports.middlewares = require('./testCommand/middlewares').default;
9
9
 
10
10
  module.exports.handler = async function test({ detoxArgs, runnerArgs }) {
11
11
  try {
12
- await detox.init({
12
+ const opts = {
13
13
  argv: detoxArgs,
14
14
  testRunnerArgv: runnerArgs,
15
15
  workerId: null,
16
- });
16
+ };
17
+
18
+ const config = await detox.resolveConfig(opts);
19
+ if (!config.testRunner.inspectBrk) {
20
+ await detox.init(opts);
21
+ }
17
22
 
18
23
  const runnerCommand = new TestRunnerCommand()
19
- .setRunnerConfig(detox.config.testRunner)
20
24
  .setDeviceConfig(detox.config.device)
21
- .replicateCLIConfig(detox.config.cli);
25
+ .replicateCLIConfig(detox.config.cli)
26
+ .setRunnerConfig(detox.config.testRunner);
22
27
 
23
28
  await runnerCommand.execute();
24
29
  } finally {
@@ -36,9 +36,8 @@ class TestRunnerCommand {
36
36
  */
37
37
  setRunnerConfig(config) {
38
38
  this._argv = config.args;
39
- this._retries = config.retries;
40
-
41
- if (config.inspectBrk === true) {
39
+ this._retries = config.inspectBrk ? 0 : config.retries;
40
+ if (config.inspectBrk || config.forwardEnv) {
42
41
  this._env = this._envHint;
43
42
  }
44
43
 
@@ -105,11 +104,13 @@ class TestRunnerCommand {
105
104
  throw e;
106
105
  }
107
106
 
108
- this._argv._ = testFilesToRetry.splice(0, Infinity);
109
- // @ts-ignore
110
- detox.session.testSessionIndex++; // it is always a primary context, so we can update it
107
+ if (--runsLeft > 0) {
108
+ this._argv._ = testFilesToRetry.splice(0, Infinity);
109
+ // @ts-ignore
110
+ detox.session.testSessionIndex++; // it is always a primary context, so we can update it
111
+ }
111
112
  }
112
- } while (launchError && --runsLeft > 0);
113
+ } while (launchError && runsLeft > 0);
113
114
 
114
115
  if (launchError) {
115
116
  throw launchError;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "detox",
3
3
  "description": "E2E tests and automation for mobile",
4
- "version": "20.0.5-breaking.new-global-lifecycle.0",
4
+ "version": "20.0.8-prerelease.0",
5
5
  "bin": {
6
6
  "detox": "local-cli/cli.js"
7
7
  },
@@ -49,7 +49,7 @@
49
49
  "jest": "^28.0.0",
50
50
  "mockdate": "^2.0.1",
51
51
  "prettier": "1.7.0",
52
- "react-native": "0.68.2",
52
+ "react-native": "0.69.5",
53
53
  "react-native-codegen": "^0.0.8",
54
54
  "typescript": "^4.5.2",
55
55
  "wtfnode": "^0.9.1"
@@ -184,5 +184,5 @@
184
184
  }
185
185
  }
186
186
  },
187
- "gitHead": "e299576e350a493084cf00a3007e5dd1ae03c3d5"
187
+ "gitHead": "205099aa94b9c7c5e0fa47985e24255f8aee3b1b"
188
188
  }
@@ -1,5 +1,6 @@
1
- // @ts-nocheck
2
- const maybeNodeEnvironment = require('jest-environment-node'); // eslint-disable-line node/no-extraneous-require
1
+ const resolveFrom = require('resolve-from');
2
+ const maybeNodeEnvironment = require(resolveFrom(process.cwd(), 'jest-environment-node'));
3
+ // @ts-ignore
3
4
  const NodeEnvironment = maybeNodeEnvironment.default || maybeNodeEnvironment;
4
5
 
5
6
  const detox = require('../../../internals');
@@ -129,7 +130,7 @@ class DetoxCircusEnvironment extends NodeEnvironment {
129
130
  async initDetox() {
130
131
  const opts = {
131
132
  global: this.global,
132
- workerId: `worker-${process.env.JEST_WORKER_ID}`,
133
+ workerId: `w${process.env.JEST_WORKER_ID}`,
133
134
  };
134
135
 
135
136
  if (this._shouldManageDetox) {
@@ -195,7 +195,6 @@ class DetoxWorker {
195
195
  onTestStart = async (testSummary) => {
196
196
  if (this._isCleaningUp) return;
197
197
  this._validateTestSummary('beforeEach', testSummary);
198
- this._logTestRunCheckpoint('DETOX_BEFORE_EACH', testSummary);
199
198
 
200
199
  if (this._isCleaningUp) return;
201
200
  await this._dumpUnhandledErrorsIfAny({
@@ -215,7 +214,6 @@ class DetoxWorker {
215
214
  onTestDone = async (testSummary) => {
216
215
  if (this._isCleaningUp) return;
217
216
  this._validateTestSummary('afterEach', testSummary);
218
- this._logTestRunCheckpoint('DETOX_AFTER_EACH', testSummary);
219
217
 
220
218
  if (this._isCleaningUp) return;
221
219
  await this._artifactsManager.onTestDone(testSummary);
@@ -251,10 +249,6 @@ class DetoxWorker {
251
249
  }
252
250
  }
253
251
 
254
- _logTestRunCheckpoint(event, { status, fullName }) {
255
- this.log.trace({ event, status }, `${status} test: ${JSON.stringify(fullName)}`);
256
- }
257
-
258
252
  _validateTestSummary(methodName, testSummary) {
259
253
  if (!_.isPlainObject(testSummary)) {
260
254
  throw this._runtimeErrorComposer.invalidTestSummary(methodName, testSummary);
@@ -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
- return await new ActionInteraction(this._invocationManager, this, new actions.TapAction(value)).execute();
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
- return await new ActionInteraction(this._invocationManager, this, new actions.TapAtPointAction(value)).execute();
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
- return await new ActionInteraction(this._invocationManager, this, new actions.LongPressAction()).execute();
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
- return await new ActionInteraction(this._invocationManager, this, new actions.MultiClickAction(times)).execute();
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
- return await new ActionInteraction(this._invocationManager, this, new actions.PressKeyAction(67)).execute();
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
- return await new ActionInteraction(this._invocationManager, this, new actions.TypeTextAction('\n')).execute();
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
- return await new ActionInteraction(this._invocationManager, this, new actions.TypeTextAction(value)).execute();
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
- return await new ActionInteraction(this._invocationManager, this, new actions.ReplaceTextAction(value)).execute();
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
- return await new ActionInteraction(this._invocationManager, this, new actions.ClearTextAction()).execute();
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
- // override the user's element selection with an extended matcher that looks for UIScrollView children
72
- // this._selectElementWithMatcher(this._originalMatcher._extendToDescendantScrollViews());
73
- return await new ActionInteraction(this._invocationManager, this, new actions.ScrollAmountAction(direction, amount, startPositionX, startPositionY)).execute();
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
- return await new ActionInteraction(this._invocationManager, this, new actions.ScrollEdgeAction(edge)).execute();
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
- return await new ActionInteraction(this._invocationManager, this, new actions.ScrollToIndex(index)).execute();
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
- return await new ActionInteraction(this._invocationManager, this, action).execute();
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 resultBase64 = await new ActionInteraction(this._invocationManager, this, new actions.TakeElementScreenshot()).execute();
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 result = await new ActionInteraction(this._invocationManager, this, new actions.GetAttributes()).execute();
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
- return await new ActionInteraction(this._invocationManager, this, new actions.AdjustSliderToPosition(newPosition)).execute();
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
- return await new MatcherAssertionInteraction(this._invocationManager, this._element, this._notCondition ? new matchers.VisibleMatcher(pct).not : new matchers.VisibleMatcher(pct)).execute();
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
- return await new MatcherAssertionInteraction(this._invocationManager, this._element, this._notCondition ? new matchers.ExistsMatcher().not : new matchers.ExistsMatcher()).execute();
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
- return await new MatcherAssertionInteraction(this._invocationManager, this._element, this._notCondition ? new matchers.TextMatcher(text).not : new matchers.TextMatcher(text)).execute();
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
- return await new MatcherAssertionInteraction(this._invocationManager, this._element, this._notCondition ? new matchers.LabelMatcher(value).not : new matchers.LabelMatcher(value)).execute();
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
- return await new MatcherAssertionInteraction(this._invocationManager, this._element, this._notCondition ? new matchers.IdMatcher(value).not : new matchers.IdMatcher(value)).execute();
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
- return await new MatcherAssertionInteraction(this._invocationManager, this._element, this._notCondition ? new matchers.ValueMatcher(value).not : new matchers.ValueMatcher(value)).execute();
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
- return await new MatcherAssertionInteraction(this._invocationManager, this._element, this._notCondition ? new matchers.ToggleMatcher(value).not : new matchers.ToggleMatcher(value)).execute();
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
- return await new MatcherAssertionInteraction(this._invocationManager, this._element, this._notCondition ? new matchers.SliderPositionMatcher(value, tolerance).not : new matchers.SliderPositionMatcher(value, tolerance)).execute();
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
- return await new MatcherAssertionInteraction(this._invocationManager, this._element, this._notCondition ? new matchers.FocusMatcher().not : new matchers.FocusMatcher()).execute();
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,6 @@
1
1
  const DetoxRuntimeError = require('../../errors/DetoxRuntimeError');
2
+ const { expectDescription, actionDescription } = require('../../utils/invocationTraceDescriptions');
3
+ const { trace } = require('../../utils/trace');
2
4
  const { ScrollAmountStopAtEdgeAction } = require('../actions/native');
3
5
  const { NativeMatcher } = require('../core/NativeMatcher');
4
6
  const DetoxAssertionApi = require('../espressoapi/DetoxAssertion');
@@ -9,45 +11,50 @@ function call(maybeAFunction) {
9
11
  }
10
12
 
11
13
  class Interaction {
12
- constructor(invocationManager) {
14
+ constructor(invocationManager, traceDescription) {
13
15
  this._call = undefined;
16
+ this._traceDescription = traceDescription;
14
17
  this._invocationManager = invocationManager;
15
18
  }
16
19
 
17
20
  async execute() {
18
- const resultObj = await this._invocationManager.execute(this._call);
19
- return resultObj ? resultObj.result : undefined;
21
+ return trace.invocationCall(this._traceDescription, this._call,
22
+ this._invocationManager.execute(this._call).then((resultObj) => resultObj ? resultObj.result : undefined));
20
23
  }
21
24
  }
22
25
 
23
26
  class ActionInteraction extends Interaction {
24
- constructor(invocationManager, element, action) {
25
- super(invocationManager);
27
+ constructor(invocationManager, element, action, traceDescription) {
28
+ super(invocationManager, traceDescription);
26
29
  this._call = EspressoDetoxApi.perform(call(element._call), action._call);
27
30
  // TODO: move this.execute() here from the caller
28
31
  }
29
32
  }
30
33
 
31
34
  class MatcherAssertionInteraction extends Interaction {
32
- constructor(invocationManager, element, matcher) {
33
- super(invocationManager);
35
+ constructor(invocationManager, element, matcher, notCondition, traceDescription) {
36
+ traceDescription = expectDescription.full(traceDescription, notCondition);
37
+ super(invocationManager, traceDescription);
38
+
39
+ matcher = notCondition ? matcher.not : matcher;
34
40
  this._call = DetoxAssertionApi.assertMatcher(call(element._call), matcher._call.value);
35
41
  // TODO: move this.execute() here from the caller
36
42
  }
37
43
  }
38
44
 
39
45
  class WaitForInteraction extends Interaction {
40
- constructor(invocationManager, element, assertionMatcher) {
41
- super(invocationManager);
46
+ constructor(invocationManager, element, assertionMatcher, expectTraceDescription) {
47
+ super(invocationManager, expectTraceDescription);
42
48
  this._element = element;
43
49
  this._assertionMatcher = assertionMatcher;
44
50
  this._element._selectElementWithMatcher(this._element._originalMatcher);
45
51
  }
46
52
 
47
53
  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');
54
+ if (typeof timeout !== 'number') throw new DetoxRuntimeError({ message: `WaitForInteraction withTimeout argument must be a number, got ${typeof timeout}` });
55
+ if (timeout < 0) throw new DetoxRuntimeError({ message: 'timeout must be larger than 0' });
50
56
 
57
+ this._traceDescription = expectDescription.waitForWithTimeout(this._traceDescription, timeout);
51
58
  this._call = DetoxAssertionApi.waitForAssertMatcher(call(this._element._call), this._assertionMatcher._call.value, timeout / 1000);
52
59
  await this.execute();
53
60
  }
@@ -58,20 +65,18 @@ class WaitForInteraction extends Interaction {
58
65
  }
59
66
 
60
67
  class WaitForActionInteractionBase extends Interaction {
61
- constructor(invocationManager, element, matcher, searchMatcher) {
62
- super(invocationManager);
63
- //if (!(element instanceof NativeElement)) throw new DetoxRuntimeError(`WaitForActionInteraction ctor 1st argument must be a valid NativeElement, got ${typeof element}`);
64
- //if (!(matcher instanceof NativeMatcher)) throw new DetoxRuntimeError(`WaitForActionInteraction ctor 2nd argument must be a valid NativeMatcher, got ${typeof matcher}`);
68
+ constructor(invocationManager, element, matcher, searchMatcher, traceDescription) {
69
+ super(invocationManager, traceDescription);
70
+
65
71
  if (!(searchMatcher instanceof NativeMatcher))
66
- throw new DetoxRuntimeError(`WaitForActionInteraction ctor 3rd argument must be a valid NativeMatcher, got ${typeof searchMatcher}`);
72
+ throw new DetoxRuntimeError({ message: `WaitForActionInteraction ctor 3rd argument must be a valid NativeMatcher, got ${typeof searchMatcher}` });
73
+
67
74
  this._element = element;
68
75
  this._originalMatcher = matcher;
69
76
  this._searchMatcher = searchMatcher;
70
77
  }
71
78
 
72
79
  _prepare(searchAction) {
73
- //if (!searchAction instanceof Action) throw new DetoxRuntimeError(`WaitForActionInteraction _execute argument must be a valid Action, got ${typeof searchAction}`);
74
-
75
80
  this._call = DetoxAssertionApi.waitForAssertMatcherWithSearchAction(
76
81
  call(this._element._call),
77
82
  call(this._originalMatcher._call).value,
@@ -83,6 +88,7 @@ class WaitForActionInteractionBase extends Interaction {
83
88
 
84
89
  class WaitForActionInteraction extends WaitForActionInteractionBase {
85
90
  async scroll(amount, direction = 'down', scrollPositionX, scrollPositionY) {
91
+ this._traceDescription = expectDescription.waitFor(actionDescription.scroll(amount, direction, scrollPositionX, scrollPositionY));
86
92
  this._prepare(new ScrollAmountStopAtEdgeAction(direction, amount, scrollPositionX, scrollPositionY));
87
93
  await this.execute();
88
94
  }
@@ -0,0 +1,7 @@
1
+ const TIMELINE_CONTEXT_TYPES = {
2
+ TEST: 'test',
3
+ DESCRIBE: 'describe',
4
+ INVOCATION: 'invocation'
5
+ };
6
+
7
+ module.exports = TIMELINE_CONTEXT_TYPES;