detox 19.9.1 → 20.0.2-breaking.new-global-lifecycle.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. package/Detox-android/com/wix/detox/{19.9.1/detox-19.9.1-javadoc.jar → 20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-javadoc.jar} +0 -0
  2. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-javadoc.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +1 -0
  5. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +1 -0
  6. package/Detox-android/com/wix/detox/{19.9.1/detox-19.9.1-sources.jar → 20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-sources.jar} +0 -0
  7. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-sources.jar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-sources.jar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-sources.jar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-sources.jar.sha512 +1 -0
  11. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.aar +0 -0
  12. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.aar.md5 +1 -0
  13. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.aar.sha1 +1 -0
  14. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.aar.sha256 +1 -0
  15. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.aar.sha512 +1 -0
  16. package/Detox-android/com/wix/detox/{19.9.1/detox-19.9.1.pom → 20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.pom} +1 -1
  17. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.pom.md5 +1 -0
  18. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.pom.sha1 +1 -0
  19. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.pom.sha256 +1 -0
  20. package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.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/detox/src/full/java/com/wix/detox/Detox.java +2 -59
  29. package/android/detox/src/full/java/com/wix/detox/NotificationDataParser.kt +3 -3
  30. package/index.d.ts +213 -186
  31. package/index.js +1 -0
  32. package/internals.d.ts +131 -0
  33. package/internals.js +4 -0
  34. package/local-cli/build-framework-cache.js +2 -2
  35. package/local-cli/build.js +7 -8
  36. package/local-cli/build.test.js +46 -40
  37. package/local-cli/clean-framework-cache.js +3 -3
  38. package/local-cli/cli.js +0 -1
  39. package/local-cli/init.js +20 -55
  40. package/local-cli/templates/jest.js +9 -34
  41. package/local-cli/test.js +18 -282
  42. package/local-cli/test.test.js +337 -672
  43. package/local-cli/testCommand/TestRunnerCommand.js +156 -0
  44. package/local-cli/{utils/testCommandArgs.js → testCommand/builder.js} +10 -35
  45. package/local-cli/testCommand/middlewares.js +75 -0
  46. package/local-cli/{utils → testCommand}/warnings.js +0 -10
  47. package/local-cli/utils/jestInternals.js +13 -2
  48. package/local-cli/utils/yargsUtils.js +67 -0
  49. package/package.json +26 -20
  50. package/runners/deprecation.js +47 -0
  51. package/runners/jest/JestCircusEnvironment.js +3 -38
  52. package/runners/jest/adapter.d.ts +4 -10
  53. package/runners/jest/adapter.js +3 -6
  54. package/runners/jest/assignReporter.d.ts +4 -1
  55. package/runners/jest/assignReporter.js +3 -6
  56. package/runners/jest/deprecation.js +25 -0
  57. package/runners/jest/globalSetup.js +1 -0
  58. package/runners/jest/globalTeardown.js +1 -0
  59. package/runners/jest/index.js +21 -0
  60. package/runners/jest/reporter.js +1 -0
  61. package/runners/jest/reporters/DetoxReporter.js +5 -0
  62. package/runners/jest/specReporter.d.ts +4 -9
  63. package/runners/jest/specReporter.js +3 -10
  64. package/runners/jest/streamlineReporter.js +3 -22
  65. package/runners/jest/testEnvironment/index.js +155 -0
  66. package/runners/{jest-circus → jest/testEnvironment}/listeners/DetoxCoreListener.js +36 -22
  67. package/runners/{jest-circus → jest/testEnvironment}/listeners/DetoxInitErrorListener.js +1 -1
  68. package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +27 -0
  69. package/runners/jest/{SpecReporterImpl.js → testEnvironment/listeners/SpecReporter.js} +61 -7
  70. package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +34 -0
  71. package/runners/jest/testEnvironment/listeners/index.js +13 -0
  72. package/runners/{jest-circus → jest/testEnvironment}/utils/assertExistingContext.js +2 -2
  73. package/runners/jest/testEnvironment/utils/assertJestCircus27.js +56 -0
  74. package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +23 -0
  75. package/runners/jest/{utils → testEnvironment/utils}/getFullTestName.js +0 -0
  76. package/runners/jest/{utils → testEnvironment/utils}/hasTimedOut.js +0 -0
  77. package/runners/jest/{utils → testEnvironment/utils}/index.js +0 -0
  78. package/runners/jest/{utils → testEnvironment/utils}/stdout.js +0 -0
  79. package/runners/jest-circus/environment/index.js +6 -0
  80. package/runners/jest-circus/index.js +1 -10
  81. package/runners/jest-circus/reporter.js +1 -0
  82. package/runners/migration.js +37 -0
  83. package/runners/mocha/DetoxMochaAdapter.js +3 -35
  84. package/runners/mocha/adapter.d.ts +4 -7
  85. package/runners/mocha/adapter.js +3 -5
  86. package/src/{Detox.js → DetoxWorker.js} +131 -164
  87. package/src/artifacts/ArtifactsManager.js +51 -2
  88. package/src/artifacts/providers/index.js +0 -4
  89. package/src/artifacts/utils/buildDefaultArtifactsRootDirpath.js +2 -4
  90. package/src/artifacts/utils/temporaryPath.js +2 -0
  91. package/src/client/AsyncWebSocket.js +1 -1
  92. package/src/client/actions/actions.js +2 -2
  93. package/src/configuration/collectCliConfig.js +2 -4
  94. package/src/configuration/composeAppsConfig.js +8 -66
  95. package/src/configuration/composeArtifactsConfig.js +6 -32
  96. package/src/configuration/composeBehaviorConfig.js +3 -13
  97. package/src/configuration/composeDeviceConfig.js +37 -62
  98. package/src/configuration/composeLoggerConfig.js +50 -0
  99. package/src/configuration/composeRunnerConfig.js +75 -14
  100. package/src/configuration/composeSessionConfig.js +1 -3
  101. package/src/configuration/index.js +24 -23
  102. package/src/configuration/utils/deviceAppTypes.js +0 -1
  103. package/src/devices/allocation/DeviceAllocator.js +3 -3
  104. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +4 -3
  105. package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +2 -6
  106. package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +1 -1
  107. package/src/devices/allocation/drivers/ios/SimulatorLauncher.js +3 -3
  108. package/src/devices/allocation/factories/index.js +0 -1
  109. package/src/devices/common/drivers/DeviceLauncher.js +2 -2
  110. package/src/devices/common/drivers/android/emulator/exec/EmulatorExec.js +1 -1
  111. package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +4 -9
  112. package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +34 -9
  113. package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +1 -1
  114. package/src/devices/runtime/RuntimeDevice.js +69 -81
  115. package/src/devices/runtime/drivers/index.js +0 -1
  116. package/src/devices/runtime/drivers/ios/SimulatorDriver.js +3 -2
  117. package/src/devices/runtime/factories/ios.js +1 -8
  118. package/src/devices/runtime/utils/LaunchArgsEditor.js +4 -59
  119. package/src/devices/runtime/utils/Storage.js +4 -0
  120. package/src/environmentFactory.js +0 -8
  121. package/src/errors/DetoxConfigErrorComposer.js +77 -30
  122. package/src/errors/DetoxError.js +4 -0
  123. package/src/errors/DetoxRuntimeError.js +5 -5
  124. package/src/errors/index.js +2 -0
  125. package/src/ipc/IPCClient.js +118 -0
  126. package/src/ipc/IPCServer.js +94 -0
  127. package/src/ipc/state.js +89 -0
  128. package/src/logger/DetoxLogger.js +244 -0
  129. package/src/logger/DetoxTraceEventBuilder.js +21 -0
  130. package/src/logger/DetoxTracer.js +133 -0
  131. package/src/logger/TraceThreadDispatcher.js +52 -0
  132. package/src/{utils → logger}/customConsoleLogger.js +1 -1
  133. package/src/realms/DetoxConstants.js +13 -0
  134. package/src/realms/DetoxContext.js +170 -0
  135. package/src/realms/DetoxInternalsFacade.js +35 -0
  136. package/src/realms/DetoxPrimaryContext.js +229 -0
  137. package/src/realms/DetoxSecondaryContext.js +94 -0
  138. package/src/realms/index.js +10 -0
  139. package/src/realms/primary.js +3 -0
  140. package/src/realms/secondary.js +3 -0
  141. package/src/server/DetoxConnection.js +1 -1
  142. package/src/symbols.js +56 -0
  143. package/src/utils/Timer.js +14 -6
  144. package/{local-cli/utils/misc.js → src/utils/envUtils.js} +0 -9
  145. package/src/utils/logger.js +2 -162
  146. package/src/utils/shellUtils.js +18 -0
  147. package/src/utils/streamUtils.js +214 -0
  148. package/src/utils/trace.js +9 -44
  149. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-javadoc.jar.md5 +0 -1
  150. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-javadoc.jar.sha1 +0 -1
  151. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-javadoc.jar.sha256 +0 -1
  152. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-javadoc.jar.sha512 +0 -1
  153. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-sources.jar.md5 +0 -1
  154. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-sources.jar.sha1 +0 -1
  155. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-sources.jar.sha256 +0 -1
  156. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-sources.jar.sha512 +0 -1
  157. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.aar +0 -0
  158. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.aar.md5 +0 -1
  159. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.aar.sha1 +0 -1
  160. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.aar.sha256 +0 -1
  161. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.aar.sha512 +0 -1
  162. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.pom.md5 +0 -1
  163. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.pom.sha1 +0 -1
  164. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.pom.sha256 +0 -1
  165. package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.pom.sha512 +0 -1
  166. package/local-cli/templates/mocha.js +0 -32
  167. package/local-cli/utils/splitArgv.js +0 -107
  168. package/runners/integration.js +0 -16
  169. package/runners/jest/DetoxAdapterCircus.js +0 -60
  170. package/runners/jest/DetoxAdapterImpl.js +0 -81
  171. package/runners/jest/DetoxAdapterJasmine.js +0 -67
  172. package/runners/jest/DetoxStreamlineJestReporter.js +0 -98
  173. package/runners/jest/FailingTestsReporter.js +0 -16
  174. package/runners/jest/SpecReporterCircus.js +0 -51
  175. package/runners/jest/SpecReporterJasmine.js +0 -39
  176. package/runners/jest/WorkerAssignReporterCircus.js +0 -17
  177. package/runners/jest/WorkerAssignReporterImpl.js +0 -21
  178. package/runners/jest/WorkerAssignReporterJasmine.js +0 -15
  179. package/runners/jest/runnerInfo.js +0 -9
  180. package/runners/jest-circus/environment.js +0 -206
  181. package/runners/jest-circus/utils/assertJestCircus26.js +0 -39
  182. package/runners/jest-circus/utils/wrapErrorWithNoopLifecycle.js +0 -14
  183. package/src/DetoxConstants.js +0 -13
  184. package/src/DetoxExportWrapper.js +0 -140
  185. package/src/artifacts/timeline/TimelineArtifactPlugin.js +0 -95
  186. package/src/devices/allocation/drivers/NoneAllocDriver.js +0 -10
  187. package/src/devices/allocation/factories/none.js +0 -11
  188. package/src/index.js +0 -6
  189. package/src/utils/MissingDetox.js +0 -78
  190. package/src/utils/fakeTimestampsProvider.js +0 -9
  191. package/src/utils/getWorkerId.js +0 -5
  192. package/src/utils/lastFailedTests.js +0 -38
  193. package/src/utils/sh.js +0 -18
@@ -1,67 +0,0 @@
1
- const _ = require('lodash');
2
-
3
- const DetoxAdapter = require('./DetoxAdapterImpl');
4
-
5
- class DetoxAdapterJasmine /* extends JasmineReporter */ {
6
- constructor(detox) {
7
- this._adapter = new DetoxAdapter(detox, DetoxAdapterJasmine._describeInitError);
8
- }
9
-
10
- static _describeInitError() {
11
- return {
12
- message: 'Detox adapter to Jest is malfunctioning.',
13
- hint: `Make sure you register it as Jasmine reporter inside init.js:\n` +
14
- `-------------------------------------------------------------\n` +
15
- 'jasmine.getEnv().addReporter(adapter);',
16
- };
17
- }
18
-
19
- async beforeEach() {
20
- await this._adapter.beforeEach();
21
- }
22
-
23
- async afterAll() {
24
- await this._adapter.afterAll();
25
- }
26
-
27
- async suiteStarted(result) {
28
- await this._adapter.suiteStart({ name: result.description });
29
- }
30
-
31
- async suiteDone(result) {
32
- await this._adapter.suiteEnd({ name: result.description });
33
- }
34
-
35
- specStarted(result) {
36
- if (result.pendingReason) {
37
- return;
38
- }
39
-
40
- this._adapter.testStart({
41
- title: result.description,
42
- fullName: result.fullName,
43
- status: 'running',
44
- });
45
- }
46
-
47
- specDone(result) {
48
- if (result.status === 'disabled' || result.pendingReason) {
49
- return;
50
- }
51
-
52
- this._adapter.testComplete({
53
- status: result.status,
54
- timedOut: this._hasTimedOut(result),
55
- });
56
- }
57
-
58
- _hasTimedOut(result) {
59
- return _.chain(result.failedExpectations)
60
- .map('error')
61
- .compact()
62
- .some(e => _.includes(e.message, 'Timeout'))
63
- .value();
64
- }
65
- }
66
-
67
- module.exports = DetoxAdapterJasmine;
@@ -1,98 +0,0 @@
1
- // @ts-nocheck
2
- const { VerboseReporter: JestVerboseReporter } = require('@jest/reporters'); // eslint-disable-line node/no-extraneous-require
3
-
4
- const DetoxRuntimeError = require('../../src/errors/DetoxRuntimeError');
5
-
6
- class DetoxStreamlineJestReporter extends JestVerboseReporter {
7
-
8
- constructor(globalConfig) {
9
- super(globalConfig);
10
- this._assertConfig();
11
- }
12
-
13
- /**
14
- * Monkey patch for _wrapStdio method of Jest's DefaultReporter class
15
- * https://github.com/facebook/jest/blob/84466b7bb187d33ffd336bd9fc76111bba511fe6/packages/jest-reporters/src/default_reporter.ts#L47
16
- *
17
- * The official implementation does the following:
18
- * - For the <b>stderr</b> stream, it overrides the 'write' method with a simple bulked output mechanism,
19
- * which aggregates output onto a buffer but flushes it immediately.
20
- * - For the <b>stdout</b> stream, it overrides the 'write' method with a time-based bulked output mechanism,
21
- * which aggregates output onto a buffer and flushes only in 100ms intervals.
22
- *
23
- * This gives priority, to a certain extent, to stderr output, over stdout.
24
- * See: https://github.com/facebook/jest/blob/84466b7bb187d33ffd336bd9fc76111bba511fe6/packages/jest-reporters/src/default_reporter.ts#L73
25
- *
26
- * Typically, user logs are sent to stdout, and Jest reporter's (e.g. test-suite summary) - to stderr.
27
- *
28
- * ---
29
- * Our goal is to have these 3 types of output streamlined in real time:
30
- *
31
- * 1. Jest suite-level lifecycle logging, typically done by the super-class' impl.
32
- * Note: Jest does not notify spec-level events to reporters.
33
- * 2. Jasmine real-time, spec-level lifecycle logging.
34
- * 3. User in-test logging (e.g. for debugging).
35
- *
36
- * It's easy to see that this cannot be done while stderr and stdout are not of equal priority.
37
- * Therefore, this hack enforces immediate-flushing approach to <b>both</b> stderr and stdout.
38
- */
39
- _wrapStdio(stream) {
40
- const originalWrite = stream.write;
41
- let buffer = [];
42
-
43
- const flushBufferedOutput = () => {
44
- const string = buffer.join('');
45
- buffer = []; // This is to avoid conflicts between random output and status text
46
-
47
- this._clearStatus();
48
-
49
- if (string) {
50
- originalWrite.call(stream, string);
51
- }
52
-
53
- this._printStatus();
54
-
55
- this._bufferedOutput.delete(flushBufferedOutput);
56
- };
57
-
58
- this._bufferedOutput.add(flushBufferedOutput);
59
-
60
- stream.write = chunk => {
61
- buffer.push(chunk);
62
- flushBufferedOutput();
63
- return true;
64
- };
65
- }
66
-
67
- _assertConfig() {
68
- if (!this._isVerboseEnabled()) {
69
- // Non-verbose mode makes Jest swizzle 'console' with a buffered output impl, which prevents
70
- // user and detox' jasmine-lifecycle logs from showing in real time.
71
- throw new DetoxRuntimeError({
72
- message: 'Cannot run properly unless Jest is in verbose mode',
73
- hint: 'See https://jestjs.io/docs/en/configuration#verbose-boolean for more details',
74
- });
75
- }
76
-
77
- if (this._hasDefaultReporter()) {
78
- // This class overrides Jest's VerboseReporter, which is set by default. Can't have both.
79
- throw new DetoxRuntimeError({
80
- message: 'Cannot work alongside the default Jest reporter. Please remove it from the reporters list.',
81
- hint: 'See https://jestjs.io/docs/en/configuration#reporters-array-modulename-modulename-options for more details',
82
- });
83
- }
84
- }
85
-
86
- _isVerboseEnabled() {
87
- return !!this._globalConfig.verbose;
88
- }
89
-
90
- _hasDefaultReporter() {
91
- return !!this._globalConfig.reporters.find(reporterDef => {
92
- const [reporterName] = reporterDef;
93
- return reporterName === 'default';
94
- });
95
- }
96
- }
97
-
98
- module.exports = DetoxStreamlineJestReporter;
@@ -1,16 +0,0 @@
1
- const path = require('path');
2
-
3
- const { saveLastFailedTests } = require('../../src/utils/lastFailedTests');
4
-
5
- class FailingTestsReporter {
6
- async onRunComplete(_contexts, { testResults }) {
7
- const cwd = process.cwd();
8
- const failedFiles = testResults
9
- .filter(result => result.numFailingTests > 0)
10
- .map(result => path.relative(cwd, result.testFilePath));
11
-
12
- await saveLastFailedTests(failedFiles);
13
- }
14
- }
15
-
16
- module.exports = FailingTestsReporter;
@@ -1,51 +0,0 @@
1
- const argparse = require('../../src/utils/argparse');
2
-
3
- const SpecReporter = require('./SpecReporterImpl');
4
-
5
- class SpecReporterCircus {
6
- constructor() {
7
- this._specReporter = new SpecReporter();
8
- }
9
-
10
- run_describe_start(event) {
11
- if (event.describeBlock.parent !== undefined) {
12
- this._specReporter.onSuiteStart({
13
- description: event.describeBlock.name,
14
- });
15
- }
16
- }
17
-
18
- run_describe_finish(event) {
19
- if (event.describeBlock.parent !== undefined) {
20
- this._specReporter.onSuiteEnd();
21
- }
22
- }
23
-
24
- test_start(event) {
25
- const { test } = event;
26
- this._specReporter.onTestStart({
27
- description: test.name,
28
- invocations: test.invocations,
29
- });
30
- }
31
-
32
- test_done(event) {
33
- const { test } = event;
34
- const testInfo = {
35
- description: test.name,
36
- invocations: test.invocations,
37
- };
38
- this._specReporter.onTestEnd(testInfo, test.errors.length ? 'failed' : 'success');
39
- }
40
-
41
- test_skip(event) {
42
- const testInfo = {
43
- description: event.test.name,
44
- };
45
- this._specReporter.onTestEnd(testInfo, 'skipped');
46
- }
47
- }
48
-
49
- module.exports = argparse.getArgValue('reportSpecs') === 'true'
50
- ? SpecReporterCircus
51
- : class {};
@@ -1,39 +0,0 @@
1
- const SpecReporter = require('./SpecReporterImpl');
2
-
3
- /***
4
- * @see {@link https://jasmine.github.io/api/2.9/Reporter.html}
5
- */
6
- class SpecReporterJasmine {
7
- constructor() {
8
- this._specReporter = new SpecReporter();
9
- }
10
-
11
- suiteStarted(suiteInfo) {
12
- this._specReporter.onSuiteStart(suiteInfo);
13
- }
14
-
15
- suiteDone() {
16
- this._specReporter.onSuiteEnd();
17
- }
18
-
19
- specStarted(specInfo) {
20
- this._specReporter.onTestStart(specInfo);
21
- }
22
-
23
- specDone(specResult) {
24
- let result;
25
- if (specResult.status === 'disabled') {
26
- result = 'skipped';
27
- } else if (specResult.status === 'failed') {
28
- result = 'failed';
29
- } else if (specResult.pendingReason) {
30
- result = 'pending';
31
- } else {
32
- result = 'success';
33
- }
34
-
35
- this._specReporter.onTestEnd(specResult, result);
36
- }
37
- }
38
-
39
- module.exports = SpecReporterJasmine;
@@ -1,17 +0,0 @@
1
- const WorkerAssignReporter = require('./WorkerAssignReporterImpl');
2
-
3
- class WorkerAssignReporterCircus {
4
- constructor({ detox }) {
5
- this._reporter = new WorkerAssignReporter(detox);
6
- }
7
-
8
- run_describe_start(event) {
9
- const { describeBlock } = event;
10
-
11
- if (describeBlock.parent && describeBlock.parent.parent === undefined) {
12
- this._reporter.report(describeBlock.name);
13
- }
14
- }
15
- }
16
-
17
- module.exports = WorkerAssignReporterCircus;
@@ -1,21 +0,0 @@
1
- const chalk = require('chalk').default;
2
- const _ = require('lodash');
3
-
4
- const log = require('../../src/utils/logger').child();
5
-
6
- class WorkerAssignReporterImpl {
7
- constructor(detox) {
8
- this.device = detox && detox.device;
9
- }
10
-
11
- report(workerName) {
12
- const deviceName = _.attempt(() => this.device.name);
13
- const formattedDeviceName = _.isError(deviceName)
14
- ? chalk.redBright('undefined')
15
- : chalk.blueBright(deviceName);
16
-
17
- log.info({ event: 'WORKER_ASSIGN' }, `${chalk.whiteBright(workerName)} is assigned to ${formattedDeviceName}`);
18
- }
19
- }
20
-
21
- module.exports = WorkerAssignReporterImpl;
@@ -1,15 +0,0 @@
1
- const path = require('path');
2
-
3
- const WorkerAssignReporter = require('./WorkerAssignReporterImpl');
4
-
5
- class WorkerAssignReporterJasmine {
6
- constructor({ detox }) {
7
- this._reporter = new WorkerAssignReporter(detox);
8
- }
9
-
10
- suiteStarted(suiteInfo) {
11
- const workerName = path.basename(suiteInfo.testPath);
12
- this._reporter.report(workerName);
13
- }
14
- }
15
- module.exports = WorkerAssignReporterJasmine;
@@ -1,9 +0,0 @@
1
- // @ts-nocheck
2
- const isJasmine = !!global.jasmine;
3
- const isJestCircus = !!global.detoxCircus;
4
-
5
- module.exports = {
6
- type: isJestCircus ? 'jest-circus' : 'jasmine',
7
- isJasmine,
8
- isJestCircus,
9
- };
@@ -1,206 +0,0 @@
1
- // @ts-nocheck
2
- const maybeNodeEnvironment = require('jest-environment-node'); // eslint-disable-line node/no-extraneous-require
3
- const NodeEnvironment = maybeNodeEnvironment.default || maybeNodeEnvironment;
4
-
5
- const DetoxError = require('../../src/errors/DetoxError');
6
- const Timer = require('../../src/utils/Timer');
7
-
8
- const DetoxCoreListener = require('./listeners/DetoxCoreListener');
9
- const DetoxInitErrorListener = require('./listeners/DetoxInitErrorListener');
10
- const assertExistingContext = require('./utils/assertExistingContext');
11
- const assertJestCircus26 = require('./utils/assertJestCircus26');
12
- const wrapErrorWithNoopLifecycle = require('./utils/wrapErrorWithNoopLifecycle');
13
-
14
- const SYNC_CIRCUS_EVENTS = new Set([
15
- 'start_describe_definition',
16
- 'finish_describe_definition',
17
- 'add_hook',
18
- 'add_test',
19
- 'error',
20
- ]);
21
-
22
- /**
23
- * @see https://www.npmjs.com/package/jest-circus#overview
24
- */
25
- class DetoxCircusEnvironment extends NodeEnvironment {
26
- constructor(config, context) {
27
- super(assertJestCircus26(config), assertExistingContext(context));
28
-
29
- /** @private */
30
- this._timer = null;
31
- /** @private */
32
- this._listenerFactories = {
33
- DetoxInitErrorListener,
34
- DetoxCoreListener,
35
- };
36
- /** @private */
37
- this._calledDetoxInit = false;
38
- /** @private */
39
- this._calledDetoxCleanup = false;
40
- /** @protected */
41
- this.testPath = context.testPath;
42
- /** @protected */
43
- this.testEventListeners = [];
44
- /** @protected */
45
- this.initTimeout = 300000;
46
- }
47
-
48
- async setup() {
49
- await super.setup();
50
-
51
- this.global.detox = require('../../src')
52
- ._setGlobal(this.global)
53
- ._suppressLoggingInitErrors();
54
- }
55
-
56
- async teardown() {
57
- try {
58
- if (this._calledDetoxInit && !this._calledDetoxCleanup) {
59
- await this._runEmergencyTeardown();
60
- }
61
- } finally {
62
- await super.teardown();
63
- }
64
- }
65
-
66
- get detox() {
67
- return this.global.detox;
68
- }
69
-
70
- async handleTestEvent(event, state) {
71
- const { name } = event;
72
-
73
- if (SYNC_CIRCUS_EVENTS.has(name)) {
74
- return this._handleTestEventSync(event, state);
75
- }
76
-
77
- this._timer = new Timer({
78
- description: `handling jest-circus "${name}" event`,
79
- timeout: name === 'setup' ? this.initTimeout : state.testTimeout,
80
- });
81
-
82
- try {
83
- if (name === 'setup') {
84
- await this._onSetup(state);
85
- }
86
-
87
- for (const listener of this.testEventListeners) {
88
- if (typeof listener[name] === 'function') {
89
- try {
90
- await this._timer.run(() => listener[name](event, state));
91
- } catch (listenerError) {
92
- this._logError(listenerError);
93
- }
94
- }
95
- }
96
-
97
- if (name === 'teardown') {
98
- await this._onTeardown(state);
99
- }
100
- } finally {
101
- this._timer.dispose();
102
- this._timer = null;
103
- }
104
- }
105
-
106
- _handleTestEventSync(event, state) {
107
- const { name } = event;
108
-
109
- for (const listener of this.testEventListeners) {
110
- if (typeof listener[name] === 'function') {
111
- listener[name](event, state);
112
- }
113
- }
114
- }
115
-
116
- async _onSetup(state) {
117
- let detox;
118
-
119
- try {
120
- detox = await this._timer.run(async () => {
121
- try {
122
- this._calledDetoxInit = true;
123
- return await this.initDetox();
124
- } catch (actualError) {
125
- state.unhandledErrors.push(actualError);
126
- this._logError(actualError);
127
- throw actualError;
128
- }
129
- });
130
- } catch (maybeActualError) {
131
- if (!state.unhandledErrors.includes(maybeActualError)) {
132
- const timeoutError = maybeActualError;
133
- state.unhandledErrors.push(timeoutError);
134
- this._logError(timeoutError);
135
- }
136
-
137
- detox = wrapErrorWithNoopLifecycle(maybeActualError);
138
- } finally {
139
- this._timer.reset(state.testTimeout);
140
- }
141
-
142
- this._instantiateListeners(detox);
143
- }
144
-
145
- _instantiateListeners(detoxInstance) {
146
- for (const Listener of Object.values(this._listenerFactories)) {
147
- this.testEventListeners.push(new Listener({
148
- detox: detoxInstance,
149
- env: this,
150
- }));
151
- }
152
- }
153
-
154
- async _onTeardown(state) {
155
- try {
156
- this._calledDetoxCleanup = true;
157
- await this._timer.run(() => this.cleanupDetox());
158
- } catch (cleanupError) {
159
- state.unhandledErrors.push(cleanupError);
160
- this._logError(cleanupError);
161
- }
162
- }
163
-
164
- async _runEmergencyTeardown() {
165
- this._timer = new Timer({
166
- description: `handling environment teardown`,
167
- timeout: this.initTimeout,
168
- });
169
-
170
- try {
171
- await this._timer.run(() => this.cleanupDetox());
172
- } catch (cleanupError) {
173
- this._logError(cleanupError);
174
- } finally {
175
- this._timer.dispose();
176
- this._timer = null;
177
- }
178
- }
179
-
180
- /** @private */
181
- get _logger() {
182
- return require('../../src/utils/logger');
183
- }
184
-
185
- /** @private */
186
- _logError(e) {
187
- this._logger.error(DetoxError.format(e));
188
- }
189
-
190
- /** @protected */
191
- async initDetox() {
192
- return this.detox.init();
193
- }
194
-
195
- /** @protected */
196
- async cleanupDetox() {
197
- return this.detox.cleanup();
198
- }
199
-
200
- /** @protected */
201
- registerListeners(map) {
202
- Object.assign(this._listenerFactories, map);
203
- }
204
- }
205
-
206
- module.exports = DetoxCircusEnvironment;
@@ -1,39 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- const DetoxRuntimeError = require('../../../src/errors/DetoxRuntimeError');
5
-
6
- function assertJestCircus26(maybeProjectConfig) {
7
- const projectConfig = maybeProjectConfig.projectConfig || maybeProjectConfig;
8
-
9
- if (!/jest-circus/.test(projectConfig.testRunner)) {
10
- throw new DetoxRuntimeError('Cannot run tests without "jest-circus" npm package, exiting.');
11
- }
12
-
13
- const circusPackageJson = path.join(path.dirname(projectConfig.testRunner), 'package.json');
14
- if (!fs.existsSync(circusPackageJson)) {
15
- throw new DetoxRuntimeError('Check that you have an installed copy of "jest-circus" npm package, exiting.');
16
- }
17
-
18
- const circusVersion = require(circusPackageJson).version || '';
19
- const [major, minor, patch] = circusVersion.split('.');
20
- if (major < 26) {
21
- throw new DetoxRuntimeError(
22
- `Cannot use older versions of "jest-circus", exiting.\n` +
23
- `You have jest-circus@${circusVersion}. Update to ^26.0.0 or newer.`
24
- );
25
- }
26
-
27
- if (major == 26 && minor == 5 && patch < 2) {
28
- throw new DetoxRuntimeError(
29
- `You have jest-circus@${circusVersion} currently installed.\n` +
30
- `Unfortunately, it is incompatible with Detox due to this critical issue:\n\n` +
31
- `https://github.com/wix/Detox/issues/2390\n\n` +
32
- `Please update to jest-circus@^26.5.2 (or newer) to proceed.`
33
- );
34
- }
35
-
36
- return maybeProjectConfig;
37
- }
38
-
39
- module.exports = assertJestCircus26;
@@ -1,14 +0,0 @@
1
- const _ = require('lodash');
2
-
3
- const lifecycleSymbols = require('../../integration').lifecycle;
4
-
5
- function wrapErrorWithNoopLifecycle(error) {
6
- const wrapper = { error };
7
- for (const symbol of Object.values(lifecycleSymbols)) {
8
- wrapper[symbol] = _.noop;
9
- }
10
-
11
- return wrapper;
12
- }
13
-
14
- module.exports = wrapErrorWithNoopLifecycle;
@@ -1,13 +0,0 @@
1
- module.exports = Object.freeze({
2
- 'userNotificationTriggers': {
3
- 'push': 'push',
4
- 'calendar': 'calendar',
5
- 'timeInterval': 'timeInterval',
6
- 'location': 'location'
7
- },
8
- 'userActivityTypes': {
9
- 'searchableItem': 'com.apple.corespotlightitem',
10
- 'browsingWeb': 'NSUserActivityTypeBrowsingWeb',
11
- },
12
- 'searchableItemActivityIdentifier': 'kCSSearchableItemActivityIdentifier'
13
- });