detox 20.1.0-next-is-hittable-check.0 → 20.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. package/Detox-android/com/wix/detox/{20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar → 20.1.0/detox-20.1.0-javadoc.jar} +0 -0
  2. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.sha256 +1 -0
  5. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.sha512 +1 -0
  6. package/Detox-android/com/wix/detox/{20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar → 20.1.0/detox-20.1.0-sources.jar} +0 -0
  7. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.sha512 +1 -0
  11. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar +0 -0
  12. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.md5 +1 -0
  13. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.sha1 +1 -0
  14. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.sha256 +1 -0
  15. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.sha512 +1 -0
  16. package/Detox-android/com/wix/detox/{20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom → 20.1.0/detox-20.1.0.pom} +1 -1
  17. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.pom.md5 +1 -0
  18. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.pom.sha1 +1 -0
  19. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.pom.sha256 +1 -0
  20. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.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 +0 -1
  29. package/android/detox/src/full/java/com/wix/detox/TestEngineFacade.kt +3 -3
  30. package/android/detox/src/full/java/com/wix/detox/adapters/server/QueryStatusActionHandler.kt +12 -80
  31. package/android/detox/src/full/java/com/wix/detox/espresso/common/UiControllerImplReflected.kt +16 -0
  32. package/android/detox/src/full/java/com/wix/detox/espresso/idlingresources/DescriptiveIdlingResource.kt +8 -0
  33. package/android/detox/src/full/java/com/wix/detox/espresso/registry/BusyResourcesInquirer.kt +48 -0
  34. package/android/detox/src/full/java/com/wix/detox/inquiry/DetoxBusyResource.kt +92 -0
  35. package/android/detox/src/full/java/com/wix/detox/{reactnative/idlingresources/IdlingResourceDescription.kt → inquiry/DetoxBusyResourceDescription.kt} +6 -6
  36. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AnimatedModuleIdlingResource.java +18 -7
  37. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResource.kt +2 -4
  38. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/BridgeIdlingResource.java +12 -6
  39. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DetoxBaseIdlingResource.java +2 -0
  40. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResource.java +14 -8
  41. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt +1 -6
  42. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIManagerModuleReflected.kt +1 -1
  43. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIModuleIdlingResource.kt +4 -6
  44. package/android/detox/src/testFull/java/com/wix/detox/adapters/server/QueryStatusActionHandlerSpec.kt +35 -94
  45. package/android/detox/src/testFull/java/com/wix/detox/espresso/registry/{IRStatusInquirerTest.kt → BusyResourcesInquirerTest.kt} +46 -7
  46. package/android/detox/src/testFull/java/com/wix/detox/{reactnative/idlingresources/IdlingResourceDescriptionSpec.kt → inquiry/DetoxBusyResourceDescriptionSpec.kt} +6 -6
  47. package/android/detox/src/testFull/java/com/wix/detox/inquiry/DetoxBusyResourceSpec.kt +134 -0
  48. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResourceSpec.kt +4 -5
  49. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResourcesTest.kt +5 -5
  50. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResourceSpec.kt +4 -6
  51. package/index.d.ts +102 -18
  52. package/internals.d.ts +34 -9
  53. package/local-cli/cli.js +6 -3
  54. package/local-cli/init.js +1 -1
  55. package/local-cli/test.js +6 -6
  56. package/local-cli/testCommand/TestRunnerCommand.js +97 -94
  57. package/local-cli/testCommand/TestRunnerError.js +17 -0
  58. package/local-cli/testCommand/builder.js +0 -1
  59. package/local-cli/testCommand/middlewares.js +4 -13
  60. package/local-cli/testCommand/warnings.js +0 -3
  61. package/package.json +18 -15
  62. package/runners/deprecation.js +42 -44
  63. package/runners/jest/index.d.ts +60 -0
  64. package/runners/jest/index.js +3 -8
  65. package/runners/jest/reporters/DetoxReporter.js +21 -10
  66. package/runners/jest/testEnvironment/index.js +57 -41
  67. package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +62 -35
  68. package/runners/jest/testEnvironment/listeners/SpecReporter.js +12 -14
  69. package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +1 -5
  70. package/runners/jest/testEnvironment/utils/assertJestCircus27.js +17 -3
  71. package/src/DetoxWorker.js +95 -49
  72. package/src/android/interactions/native.js +3 -2
  73. package/src/artifacts/ArtifactsManager.js +6 -6
  74. package/src/artifacts/utils/temporaryPath.js +32 -2
  75. package/src/client/actions/SyncStatusSchema.json +21 -0
  76. package/src/client/actions/formatters/SyncStatusFormatter.js +2 -0
  77. package/src/client/actions/formatters/sync-resources/BgThreadFormatter.js +5 -0
  78. package/src/configuration/collectCliConfig.js +1 -12
  79. package/src/configuration/composeRunnerConfig.js +5 -4
  80. package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +3 -3
  81. package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +3 -16
  82. package/src/devices/common/drivers/android/exec/ADB.js +4 -0
  83. package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +1 -1
  84. package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +4 -0
  85. package/src/devices/runtime/RuntimeDevice.js +3 -3
  86. package/src/errors/DetoxConfigErrorComposer.js +6 -1
  87. package/src/errors/DetoxError.js +5 -1
  88. package/src/ios/expectTwo.js +3 -2
  89. package/src/ipc/IPCClient.js +26 -17
  90. package/src/ipc/IPCServer.js +11 -3
  91. package/src/ipc/SessionState.js +11 -11
  92. package/src/logger/DetoxLogger.js +63 -43
  93. package/src/logger/index.js +1 -0
  94. package/src/logger/utils/BunyanLogger.js +50 -7
  95. package/src/logger/utils/CategoryThreadDispatcher.js +8 -29
  96. package/src/logger/utils/DetoxLogFinalizer.js +166 -0
  97. package/src/logger/utils/MessageStack.js +17 -6
  98. package/src/logger/utils/ThreadDispatcher.js +5 -25
  99. package/src/logger/utils/customConsoleLogger.js +22 -5
  100. package/src/logger/utils/getMainCategory.js +5 -0
  101. package/src/logger/utils/sanitizeBunyanContext.js +3 -1
  102. package/src/logger/utils/streams/BunyanTransformer.js +72 -0
  103. package/src/logger/utils/streams/ChromeTraceTransformer.js +132 -0
  104. package/src/logger/utils/streams/DetoxJSONLParser.js +31 -0
  105. package/src/logger/utils/streams/JSONLStringer.js +55 -0
  106. package/src/logger/utils/streams/index.js +7 -0
  107. package/src/logger/utils/streams/transformers.js +39 -0
  108. package/src/logger/utils/tracerLegacy.js +14 -25
  109. package/src/realms/DetoxContext.js +11 -7
  110. package/src/realms/DetoxInternalsFacade.js +0 -6
  111. package/src/realms/DetoxPrimaryContext.js +42 -87
  112. package/src/realms/DetoxSecondaryContext.js +8 -12
  113. package/src/utils/argparse.js +11 -0
  114. package/src/utils/logger.js +1 -1
  115. package/src/utils/pathUtils.js +11 -0
  116. package/src/utils/shellUtils.js +17 -0
  117. package/src/utils/traceInvocationCall.js +21 -0
  118. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.md5 +0 -1
  119. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.sha1 +0 -1
  120. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.sha256 +0 -1
  121. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.sha512 +0 -1
  122. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.md5 +0 -1
  123. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.sha1 +0 -1
  124. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.sha256 +0 -1
  125. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.sha512 +0 -1
  126. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar +0 -0
  127. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.md5 +0 -1
  128. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.sha1 +0 -1
  129. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.sha256 +0 -1
  130. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.sha512 +0 -1
  131. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.md5 +0 -1
  132. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.sha1 +0 -1
  133. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.sha256 +0 -1
  134. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.sha512 +0 -1
  135. package/android/detox/src/full/java/com/wix/detox/espresso/registry/IRStatusInquirer.kt +0 -24
  136. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DescriptiveIdlingResource.kt +0 -10
  137. package/local-cli/build.test.js +0 -104
  138. package/local-cli/run-server.test.js +0 -23
  139. package/local-cli/test.test.js +0 -569
  140. package/runners/jest/deprecation.js +0 -25
  141. package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +0 -23
  142. package/src/configuration/utils/warnings.js +0 -12
  143. package/src/logger/utils/streamUtils.js +0 -240
  144. package/src/utils/trace.js +0 -3
@@ -1,4 +1,5 @@
1
1
  const chalk = require('chalk').default;
2
+ const noop = require('lodash/noop');
2
3
 
3
4
  const { config, log, session } = require('../../../../internals');
4
5
  const { traceln } = require('../utils/stdout');
@@ -15,16 +16,21 @@ class SpecReporter {
15
16
  this._suitesDesc = '';
16
17
  }
17
18
 
18
- get enabled() {
19
+ setup() {
19
20
  const jestSection = config.testRunner.jest;
20
21
  const reportSpecs = jestSection && jestSection.reportSpecs;
21
-
22
- return reportSpecs !== undefined ? reportSpecs : session.workersCount === 1;
22
+ const enabled = reportSpecs !== undefined ? reportSpecs : session.workersCount === 1;
23
+
24
+ if (!enabled) {
25
+ this.run_describe_start = noop;
26
+ this.run_describe_finish = noop;
27
+ this.test_start = noop;
28
+ this.test_done = noop;
29
+ this.test_skip = noop;
30
+ }
23
31
  }
24
32
 
25
33
  run_describe_start(event) {
26
- if (!this.enabled) return;
27
-
28
34
  if (event.describeBlock.parent !== undefined) {
29
35
  this._onSuiteStart({
30
36
  description: event.describeBlock.name,
@@ -33,16 +39,12 @@ class SpecReporter {
33
39
  }
34
40
 
35
41
  run_describe_finish(event) {
36
- if (!this.enabled) return;
37
-
38
42
  if (event.describeBlock.parent !== undefined) {
39
43
  this._onSuiteEnd();
40
44
  }
41
45
  }
42
46
 
43
47
  test_start(event) {
44
- if (!this.enabled) return;
45
-
46
48
  const { test } = event;
47
49
  this._onTestStart({
48
50
  description: test.name,
@@ -51,8 +53,6 @@ class SpecReporter {
51
53
  }
52
54
 
53
55
  test_done(event) {
54
- if (!this.enabled) return;
55
-
56
56
  const { test } = event;
57
57
  const testInfo = {
58
58
  description: test.name,
@@ -62,8 +62,6 @@ class SpecReporter {
62
62
  }
63
63
 
64
64
  test_skip(event) {
65
- if (!this.enabled) return;
66
-
67
65
  const testInfo = {
68
66
  description: event.test.name,
69
67
  };
@@ -110,7 +108,7 @@ class SpecReporter {
110
108
  .concat(suite.description)
111
109
  .concat((index === total - 1) ? ': ' : '');
112
110
  });
113
- this._suitesDesc = chalk.bold.white(this._suitesDesc);
111
+ this._suitesDesc = chalk.bold(this._suitesDesc);
114
112
  }
115
113
 
116
114
  _traceTest({ description, invocations }, _status = undefined) {
@@ -13,7 +13,7 @@ class WorkerAssignReporter {
13
13
 
14
14
  run_start() {
15
15
  if (config.testRunner.jest.reportWorkerAssign) {
16
- log.info({ cat: 'lifecycle' }, `${this._formatTestName()} is assigned to ${this._formatDeviceName()}`);
16
+ log.info({ cat: 'lifecycle' }, `${chalk.bold(this._testName)} is assigned to ${this._formatDeviceName()}`);
17
17
  }
18
18
  }
19
19
 
@@ -25,10 +25,6 @@ class WorkerAssignReporter {
25
25
 
26
26
  return formattedDeviceName;
27
27
  }
28
-
29
- _formatTestName() {
30
- return chalk.whiteBright(this._testName);
31
- }
32
28
  }
33
29
 
34
30
  module.exports = WorkerAssignReporter;
@@ -1,8 +1,10 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
 
4
+ const resolveFrom = require('resolve-from');
4
5
  const semver = require('semver');
5
6
 
7
+ const { log } = require('../../../../internals');
6
8
  const detoxPackageJson = require('../../../../package.json');
7
9
  const { DetoxRuntimeError } = require('../../../../src/errors');
8
10
 
@@ -25,6 +27,10 @@ function assertJestCircus27(maybeProjectConfig) {
25
27
  });
26
28
  }
27
29
 
30
+ const jestManifestPath = resolveFrom(process.cwd(), 'jest/package.json');
31
+ const jestManifest = require(jestManifestPath);
32
+ assertSupportedVersion(jestManifest.version);
33
+
28
34
  const circusVersion = require(circusPackageJson).version;
29
35
  if (!circusVersion) {
30
36
  throw new DetoxRuntimeError({
@@ -33,7 +39,14 @@ function assertJestCircus27(maybeProjectConfig) {
33
39
  });
34
40
  }
35
41
 
36
- assertSupportedVersion(circusVersion);
42
+ if (jestManifest.version !== circusVersion) {
43
+ log.warn([
44
+ `jest-circus@${circusVersion} does not match jest@${jestManifest.version}.\n`,
45
+ `- jest@${jestManifest.version} resolved path:\n\t${jestManifestPath}`,
46
+ `- jest-circus@${circusVersion} resolved path:\n\t${circusPackageJson}`,
47
+ `\nPlease make sure that your versions match to avoid unexpected behavior!`,
48
+ ].join('\n'));
49
+ }
37
50
 
38
51
  return maybeProjectConfig;
39
52
  }
@@ -41,11 +54,12 @@ function assertJestCircus27(maybeProjectConfig) {
41
54
  function assertSupportedVersion(actualVersion) {
42
55
  const supportedRange = detoxPackageJson.peerDependencies.jest;
43
56
  const minSupportedVersion = semver.minVersion(supportedRange);
57
+ const action = semver.lt(actualVersion, minSupportedVersion) ? 'upgrade' : 'downgrade';
44
58
 
45
- if (semver.lt(actualVersion, minSupportedVersion)) {
59
+ if (!semver.satisfies(actualVersion, supportedRange, { includePrerelease: true })) {
46
60
  throw new DetoxRuntimeError({
47
61
  message: `Detected an unsupported jest@${actualVersion} version.`,
48
- hint: `Please upgrade your Jest test runner to the supported range: ${supportedRange}.`
62
+ hint: `Please ${action} your Jest test runner to the supported range: ${supportedRange}.`
49
63
  });
50
64
  }
51
65
  }
@@ -1,3 +1,4 @@
1
+ const CAF = require('caf');
1
2
  const _ = require('lodash');
2
3
 
3
4
  const Client = require('./client/Client');
@@ -11,7 +12,7 @@ const uuid = require('./utils/uuid');
11
12
  class DetoxWorker {
12
13
  constructor(context) {
13
14
  this._context = context;
14
- this._isCleaningUp = false;
15
+ this._injectedGlobalProperties = [];
15
16
  this._config = context[symbols.config];
16
17
  this._runtimeErrorComposer = new DetoxRuntimeErrorComposer(this._config);
17
18
  this._client = null;
@@ -32,6 +33,18 @@ class DetoxWorker {
32
33
  onError: this._onEmitError.bind(this),
33
34
  });
34
35
 
36
+
37
+ /** @type {DetoxInternals.RuntimeConfig['apps']} */
38
+ this._appsConfig = null;
39
+ /** @type {DetoxInternals.RuntimeConfig['artifacts']} */
40
+ this._artifactsConfig = null;
41
+ /** @type {DetoxInternals.RuntimeConfig['behavior']} */
42
+ this._behaviorConfig = null;
43
+ /** @type {DetoxInternals.RuntimeConfig['device']} */
44
+ this._deviceConfig = null;
45
+ /** @type {DetoxInternals.RuntimeConfig['session']} */
46
+ this._sessionConfig = null;
47
+
35
48
  /** @type {string} */
36
49
  this.id = 'worker';
37
50
  /** @type {Detox.Device} */
@@ -53,11 +66,23 @@ class DetoxWorker {
53
66
  this.trace = this._context.trace;
54
67
  /** @deprecated */
55
68
  this.traceCall = this._context.traceCall;
56
- }
57
69
 
58
- async init() {
59
- if (this._isCleaningUp) return;
70
+ this._reinstallAppsOnDevice = CAF(this._reinstallAppsOnDevice.bind(this));
71
+ this._initToken = new CAF.cancelToken();
72
+
73
+ this._cafWrap([
74
+ 'init',
75
+ 'onRunDescribeStart',
76
+ 'onTestStart',
77
+ 'onHookFailure',
78
+ 'onTestFnFailure',
79
+ 'onTestDone',
80
+ 'onRunDescribeFinish',
81
+ ]);
82
+ }
60
83
 
84
+ /** @this {DetoxWorker} */
85
+ init = function* (signal) {
61
86
  const {
62
87
  apps: appsConfig,
63
88
  artifacts: artifactsConfig,
@@ -71,6 +96,7 @@ class DetoxWorker {
71
96
  this._behaviorConfig = behaviorConfig;
72
97
  this._deviceConfig = deviceConfig;
73
98
  this._sessionConfig = sessionConfig;
99
+ // @ts-ignore
74
100
  this._sessionConfig.sessionId = sessionConfig.sessionId || uuid.UUID();
75
101
  this._runtimeErrorComposer.appsConfig = this._appsConfig;
76
102
 
@@ -82,8 +108,7 @@ class DetoxWorker {
82
108
  }
83
109
  };
84
110
 
85
- await this._client.connect();
86
- if (this._isCleaningUp) return;
111
+ yield this._client.connect();
87
112
 
88
113
  const invocationManager = new InvocationManager(this._client);
89
114
 
@@ -100,8 +125,7 @@ class DetoxWorker {
100
125
  } = environmentFactory.createFactories(this._deviceConfig);
101
126
 
102
127
  const envValidator = envValidatorFactory.createValidator();
103
- await envValidator.validate();
104
- if (this._isCleaningUp) return;
128
+ yield envValidator.validate();
105
129
 
106
130
  const commonDeps = {
107
131
  invocationManager,
@@ -112,8 +136,7 @@ class DetoxWorker {
112
136
 
113
137
  this._artifactsManager = artifactsManagerFactory.createArtifactsManager(this._artifactsConfig, commonDeps);
114
138
  this._deviceAllocator = deviceAllocatorFactory.createDeviceAllocator(commonDeps);
115
- this._deviceCookie = await this._deviceAllocator.allocate(this._deviceConfig);
116
- if (this._isCleaningUp) return;
139
+ this._deviceCookie = yield this._deviceAllocator.allocate(this._deviceConfig);
117
140
 
118
141
  this.device = runtimeDeviceFactory.createRuntimeDevice(
119
142
  this._deviceCookie,
@@ -124,7 +147,6 @@ class DetoxWorker {
124
147
  deviceConfig: this._deviceConfig,
125
148
  sessionConfig,
126
149
  });
127
- if (this._isCleaningUp) return;
128
150
 
129
151
  const matchers = matchersFactory.createMatchers({
130
152
  invocationManager,
@@ -134,34 +156,37 @@ class DetoxWorker {
134
156
  Object.assign(this, matchers);
135
157
 
136
158
  if (behaviorConfig.init.exposeGlobals) {
137
- Object.assign(DetoxWorker.global, {
159
+ const injectedGlobals = {
138
160
  ...matchers,
139
161
  device: this.device,
140
162
  detox: this,
141
- });
163
+ };
164
+
165
+ this._injectedGlobalProperties = Object.keys(injectedGlobals);
166
+ Object.assign(DetoxWorker.global, injectedGlobals);
142
167
  }
143
168
 
144
169
  // @ts-ignore
145
- await this.device.installUtilBinaries();
146
- if (this._isCleaningUp) return;
170
+ yield this.device.installUtilBinaries();
147
171
 
148
172
  if (behaviorConfig.init.reinstallApp) {
149
- await this._reinstallAppsOnDevice();
150
- if (this._isCleaningUp) return;
173
+ yield this._reinstallAppsOnDevice(signal);
151
174
  }
152
175
 
153
176
  const appAliases = Object.keys(this._appsConfig);
154
177
  if (appAliases.length === 1) {
155
- await this.device.selectApp(appAliases[0]);
178
+ yield this.device.selectApp(appAliases[0]);
156
179
  } else {
157
- await this.device.selectApp(null);
180
+ yield this.device.selectApp(null);
158
181
  }
159
-
160
- return this;
161
- }
182
+ };
162
183
 
163
184
  async cleanup() {
164
- this._isCleaningUp = true;
185
+ this._initToken.abort('CLEANUP');
186
+
187
+ for (const key of this._injectedGlobalProperties) {
188
+ delete DetoxWorker.global[key];
189
+ }
165
190
 
166
191
  if (this._artifactsManager) {
167
192
  await this._artifactsManager.onBeforeCleanup();
@@ -190,38 +215,45 @@ class DetoxWorker {
190
215
  return this._context.log;
191
216
  }
192
217
 
193
- onRunDescribeStart = async (...args) => this._artifactsManager.onRunDescribeStart(...args);
194
- onTestStart = async (testSummary) => {
195
- if (this._isCleaningUp) return;
218
+ onRunDescribeStart = function* (_signal, ...args) {
219
+ yield this._artifactsManager.onRunDescribeStart(...args);
220
+ };
221
+
222
+ onTestStart = function* (_signal, testSummary) {
196
223
  this._validateTestSummary('beforeEach', testSummary);
197
224
 
198
- if (this._isCleaningUp) return;
199
- await this._dumpUnhandledErrorsIfAny({
225
+ yield this._dumpUnhandledErrorsIfAny({
200
226
  pendingRequests: false,
201
227
  testName: testSummary.fullName,
202
228
  });
203
229
 
204
- if (this._isCleaningUp) return;
205
- await this._artifactsManager.onTestStart(testSummary);
230
+ yield this._artifactsManager.onTestStart(testSummary);
231
+ };
232
+
233
+ onHookFailure = function* (_signal, ...args) {
234
+ yield this._artifactsManager.onHookFailure(...args);
206
235
  };
207
- onHookFailure = async (...args) => this._artifactsManager.onHookFailure(...args);
208
- onTestFnFailure = async (...args) => this._artifactsManager.onTestFnFailure(...args);
209
- onTestDone = async (testSummary) => {
210
- if (this._isCleaningUp) return;
236
+
237
+ onTestFnFailure = function* (_signal, ...args) {
238
+ yield this._artifactsManager.onTestFnFailure(...args);
239
+ };
240
+
241
+ onTestDone = function* (_signal, testSummary) {
211
242
  this._validateTestSummary('afterEach', testSummary);
212
243
 
213
- if (this._isCleaningUp) return;
214
- await this._artifactsManager.onTestDone(testSummary);
244
+ yield this._artifactsManager.onTestDone(testSummary);
215
245
 
216
- if (this._isCleaningUp) return;
217
- await this._dumpUnhandledErrorsIfAny({
246
+ yield this._dumpUnhandledErrorsIfAny({
218
247
  pendingRequests: testSummary.timedOut,
219
248
  testName: testSummary.fullName,
220
249
  });
221
250
  };
222
- onRunDescribeFinish = async (...args) => this._artifactsManager.onRunDescribeFinish(...args);
223
251
 
224
- async _reinstallAppsOnDevice() {
252
+ onRunDescribeFinish = function* (_signal, ...args) {
253
+ yield this._artifactsManager.onRunDescribeFinish(...args);
254
+ };
255
+
256
+ *_reinstallAppsOnDevice(_signal) {
225
257
  const appNames = _(this._appsConfig)
226
258
  .map((config, key) => [key, `${config.binaryPath}:${config.testBinaryPath}`])
227
259
  .uniqBy(1)
@@ -229,17 +261,13 @@ class DetoxWorker {
229
261
  .value();
230
262
 
231
263
  for (const appName of appNames) {
232
- await this.device.selectApp(appName);
233
- if (this._isCleaningUp) return;
234
- await this.device.uninstallApp();
235
- if (this._isCleaningUp) return;
264
+ yield this.device.selectApp(appName);
265
+ yield this.device.uninstallApp();
236
266
  }
237
267
 
238
268
  for (const appName of appNames) {
239
- await this.device.selectApp(appName);
240
- if (this._isCleaningUp) return;
241
- await this.device.installApp();
242
- if (this._isCleaningUp) return;
269
+ yield this.device.selectApp(appName);
270
+ yield this.device.installApp();
243
271
  }
244
272
  }
245
273
 
@@ -271,10 +299,28 @@ class DetoxWorker {
271
299
  error
272
300
  );
273
301
  }
302
+
303
+ _cafWrap(methodNames) {
304
+ for (const methodName of methodNames) {
305
+ const cafMethod = CAF(this[methodName].bind(this));
306
+ this[methodName] = async (...args) => {
307
+ try {
308
+ await cafMethod(this._initToken.signal, ...args);
309
+ } catch (e) {
310
+ if (e !== 'CLEANUP') {
311
+ throw e;
312
+ }
313
+ }
314
+
315
+ return this;
316
+ };
317
+ }
318
+ }
319
+
274
320
  }
275
321
 
276
322
  /**
277
- * @type {NodeJS.Global}
323
+ * @type {NodeJS.Global | {}}
278
324
  */
279
325
  DetoxWorker.global = global;
280
326
 
@@ -1,6 +1,7 @@
1
1
  const DetoxRuntimeError = require('../../errors/DetoxRuntimeError');
2
2
  const { expectDescription, actionDescription } = require('../../utils/invocationTraceDescriptions');
3
- const { trace } = require('../../utils/trace');
3
+ const log = require('../../utils/logger').child({ cat: 'ws-client, ws' });
4
+ const traceInvocationCall = require('../../utils/traceInvocationCall').bind(null, log);
4
5
  const { ScrollAmountStopAtEdgeAction } = require('../actions/native');
5
6
  const { NativeMatcher } = require('../core/NativeMatcher');
6
7
  const DetoxAssertionApi = require('../espressoapi/DetoxAssertion');
@@ -18,7 +19,7 @@ class Interaction {
18
19
  }
19
20
 
20
21
  async execute() {
21
- return trace.invocationCall(this._traceDescription, this._call,
22
+ return traceInvocationCall(this._traceDescription, this._call,
22
23
  this._invocationManager.execute(this._call).then((resultObj) => resultObj ? resultObj.result : undefined));
23
24
  }
24
25
  }
@@ -46,13 +46,13 @@ class ArtifactsManager extends EventEmitter {
46
46
  _resolveArtifactsPathBuilder(pathBuilder, rootDir) {
47
47
  if (typeof pathBuilder === 'string') {
48
48
  pathBuilder = resolveModuleFromPath(pathBuilder);
49
+ }
49
50
 
50
- if (typeof pathBuilder === 'function') {
51
- try {
52
- pathBuilder = pathBuilder({ rootDir });
53
- } catch (e) {
54
- pathBuilder = new pathBuilder({ rootDir });
55
- }
51
+ if (typeof pathBuilder === 'function') {
52
+ try {
53
+ pathBuilder = pathBuilder({ rootDir });
54
+ } catch (e) {
55
+ pathBuilder = new pathBuilder({ rootDir });
56
56
  }
57
57
  }
58
58
 
@@ -1,14 +1,42 @@
1
1
  const path = require('path');
2
+ const { promisify } = require('util');
2
3
 
4
+ const glob = require('glob');
3
5
  const tempfile = require('tempfile');
4
6
 
7
+ const { useForwardSlashes } = require('../../utils/shellUtils');
8
+
9
+ const globSync = glob.sync;
10
+ const globAsync = promisify(glob);
11
+
12
+ function getRoot() {
13
+ return path.dirname(tempfile());
14
+ }
15
+
16
+ function createGlobber(ext) {
17
+ const fullExt = `.detox.${ext}`;
18
+
19
+ return {
20
+ sync: (pattern) => {
21
+ const cwd = getRoot();
22
+ const files = globSync(useForwardSlashes(pattern + fullExt), { cwd });
23
+ return files.map(f => path.join(cwd, f));
24
+ },
25
+ async: async (pattern) => {
26
+ const cwd = getRoot();
27
+ const files = await globAsync(useForwardSlashes(pattern + fullExt), { cwd });
28
+ return files.map(f => path.join(cwd, f));
29
+ },
30
+ };
31
+ }
32
+
5
33
  function createTempFileBuilderFn(fileExtension) {
6
34
  /**
7
35
  * @param {string} [basename]
8
36
  */
9
37
  return (basename) => {
10
38
  return basename
11
- ? path.join(path.dirname(tempfile()), `${basename}.detox.${fileExtension}`)
39
+ ? path.join(getRoot(), `${basename}.detox.${fileExtension}`)
12
40
  : tempfile(`.detox.${fileExtension}`);
13
41
  };
14
42
  }
@@ -23,5 +51,7 @@ module.exports = {
23
51
  dtxrec: createTempFileBuilderFn('dtxrec'),
24
52
  viewhierarchy: createTempFileBuilderFn('viewhierarchy'),
25
53
  },
26
- mask: () => path.join(tempfile(), '..') + path.sep + '*.detox.*',
54
+ find: {
55
+ jsonl: createGlobber('jsonl'),
56
+ },
27
57
  };
@@ -232,6 +232,27 @@
232
232
  ],
233
233
  "additionalProperties":false
234
234
  },
235
+ {
236
+ "properties":{
237
+ "name":{
238
+ "const":"bg"
239
+ },
240
+ "description":{
241
+ "type":"object",
242
+ "properties":{
243
+ "reason":{
244
+ "type":"string"
245
+ }
246
+ },
247
+ "additionalProperties":false
248
+ }
249
+ },
250
+ "required":[
251
+ "name",
252
+ "description"
253
+ ],
254
+ "additionalProperties":false
255
+ },
235
256
  {
236
257
  "properties":{
237
258
  "name":{
@@ -4,6 +4,7 @@ const Ajv = require('ajv');
4
4
  const DetoxInternalError = require('../../../errors/DetoxInternalError');
5
5
  const statusSchema = require('../SyncStatusSchema.json');
6
6
 
7
+ const bgThreadFormatter = require('./sync-resources/BgThreadFormatter');
7
8
  const delayedPerformSelectorFormatter = require('./sync-resources/DelayedPerformSelectorFormatter');
8
9
  const dispatchQueueFormatter = require('./sync-resources/DispatchQueueFormatter');
9
10
  const jsTimersFormatter = require('./sync-resources/JavaScriptTimersFormatter');
@@ -51,6 +52,7 @@ function resourcesDescriptionsFromJSON(jsonDescriptions) {
51
52
  }
52
53
 
53
54
  const resourceFormatters = {
55
+ bg: bgThreadFormatter,
54
56
  delayed_perform_selector: delayedPerformSelectorFormatter,
55
57
  dispatch_queue: dispatchQueueFormatter,
56
58
  run_loop: runLoopFormatter,
@@ -0,0 +1,5 @@
1
+ const { makeResourceTitle } = require('./utils');
2
+
3
+ module.exports = function(properties) {
4
+ return `${makeResourceTitle(`Background work taking place in ${properties.reason}.`)}`;
5
+ };
@@ -1,9 +1,6 @@
1
1
  const _ = require('lodash');
2
2
 
3
3
  const argparse = require('../utils/argparse');
4
- const log = require('../utils/logger').child({ cat: 'config' });
5
-
6
- const { DEVICE_LAUNCH_ARGS_GENERIC_DEPRECATION } = require('./utils/warnings');
7
4
 
8
5
  const asBoolean = (value) => {
9
6
  if (typeof value === 'boolean') {
@@ -25,14 +22,6 @@ const asNumber = (value) => {
25
22
  : undefined;
26
23
  };
27
24
 
28
- const deprecateDeviceLaunchArgs = (value) => {
29
- if (value) {
30
- log.warn(DEVICE_LAUNCH_ARGS_GENERIC_DEPRECATION);
31
- }
32
-
33
- return value;
34
- };
35
-
36
25
  function collectCliConfig({ argv }) {
37
26
  const env = (key) => argparse.getArgValue(key);
38
27
  const get = (key, fallback) => {
@@ -51,7 +40,7 @@ function collectCliConfig({ argv }) {
51
40
  configPath: get('config-path'),
52
41
  configuration: get('configuration'),
53
42
  debugSynchronization: asNumber(get('debug-synchronization')),
54
- deviceBootArgs: get('device-boot-args', deprecateDeviceLaunchArgs(argparse.getEnvValue('device-launch-args'))),
43
+ deviceBootArgs: get('device-boot-args'),
55
44
  appLaunchArgs: get('app-launch-args'),
56
45
  deviceName: get('device-name'),
57
46
  forceAdbInstall: asBoolean(get('force-adb-install')),
@@ -91,7 +91,7 @@ function adaptLegacyRunnerConfig(globalConfig) {
91
91
  return globalConfig.testRunner;
92
92
  }
93
93
 
94
- log.warn(`Please migrate your Detox config according to the guide:\nhttps://wix.github.io/Detox/docs/next/guide/migration\n`);
94
+ log.warn(`Please migrate your Detox config according to the guide:\nhttps://wix.github.io/Detox/docs/guide/migration\n`);
95
95
  const testRunner = globalConfig[testRunnerKey];
96
96
  const runnerConfig = globalConfig[runnerConfigKey];
97
97
  const specs = globalConfig.specs != null ? String(globalConfig.specs) : undefined;
@@ -120,9 +120,10 @@ function hasEmptyPositionalArgs(value, key) {
120
120
  * @param {Detox.DetoxTestRunnerConfig} config
121
121
  */
122
122
  function inspectBrkHookDefault(config) {
123
- config.args.$0 = /* istanbul ignore if */ os.platform() === 'win32'
124
- ? `node --inspect-brk ./node_modules/jest/bin/jest.js`
125
- : `node --inspect-brk ./node_modules/.bin/jest`;
123
+ /* istanbul ignore next */
124
+ config.args.$0 = os.platform() !== 'win32'
125
+ ? `node --inspect-brk ./node_modules/.bin/jest`
126
+ : `node --inspect-brk ./node_modules/jest/bin/jest.js`;
126
127
  config.args.runInBand = true;
127
128
  delete config.args.w;
128
129
  delete config.args.workers;
@@ -36,7 +36,7 @@ class EmulatorLauncher extends DeviceLauncher {
36
36
  retries: 2,
37
37
  interval: 100,
38
38
  conditionFn: isUnknownEmulatorError,
39
- }, () => this._launchEmulator(avdName, launchCommand));
39
+ }, () => this._launchEmulator(avdName, launchCommand, adbName));
40
40
  }
41
41
  await this._awaitEmulatorBoot(adbName);
42
42
  await this._notifyBootEvent(adbName, avdName, !isRunning);
@@ -60,8 +60,8 @@ class EmulatorLauncher extends DeviceLauncher {
60
60
  await this._notifyShutdownCompleted(adbName);
61
61
  }
62
62
 
63
- _launchEmulator(emulatorName, launchCommand) {
64
- return launchEmulatorProcess(emulatorName, this._emulatorExec, launchCommand);
63
+ _launchEmulator(emulatorName, launchCommand, adbName) {
64
+ return launchEmulatorProcess(emulatorName, this._emulatorExec, launchCommand, this._adb, adbName);
65
65
  }
66
66
 
67
67
  async _awaitEmulatorBoot(adbName) {