detox 19.9.0 → 20.0.1-breaking.new-global-lifecycle.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. package/Detox-android/com/wix/detox/{19.9.0/detox-19.9.0-javadoc.jar → 20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-javadoc.jar} +0 -0
  2. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-javadoc.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +1 -0
  5. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +1 -0
  6. package/Detox-android/com/wix/detox/{19.9.0/detox-19.9.0-sources.jar → 20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-sources.jar} +0 -0
  7. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-sources.jar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-sources.jar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-sources.jar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0-sources.jar.sha512 +1 -0
  11. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.aar +0 -0
  12. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.aar.md5 +1 -0
  13. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.aar.sha1 +1 -0
  14. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.aar.sha256 +1 -0
  15. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.aar.sha512 +1 -0
  16. package/Detox-android/com/wix/detox/{19.9.0/detox-19.9.0.pom → 20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.pom} +1 -1
  17. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.pom.md5 +1 -0
  18. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.pom.sha1 +1 -0
  19. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-breaking.new-global-lifecycle.0.pom.sha256 +1 -0
  20. package/Detox-android/com/wix/detox/20.0.1-breaking.new-global-lifecycle.0/detox-20.0.1-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/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/RN66Workaround.kt +13 -4
  31. package/index.d.ts +208 -186
  32. package/index.js +1 -0
  33. package/internals.d.ts +124 -0
  34. package/internals.js +4 -0
  35. package/local-cli/build-framework-cache.js +2 -2
  36. package/local-cli/build.js +7 -8
  37. package/local-cli/build.test.js +46 -40
  38. package/local-cli/clean-framework-cache.js +3 -3
  39. package/local-cli/cli.js +0 -1
  40. package/local-cli/init.js +20 -55
  41. package/local-cli/templates/jest.js +9 -34
  42. package/local-cli/test.js +18 -282
  43. package/local-cli/test.test.js +332 -673
  44. package/local-cli/testCommand/TestRunnerCommand.js +157 -0
  45. package/local-cli/{utils/testCommandArgs.js → testCommand/builder.js} +10 -35
  46. package/local-cli/testCommand/middlewares.js +75 -0
  47. package/local-cli/{utils → testCommand}/warnings.js +0 -10
  48. package/local-cli/utils/jestInternals.js +13 -2
  49. package/local-cli/utils/yargsUtils.js +67 -0
  50. package/package.json +26 -20
  51. package/runners/deprecation.js +47 -0
  52. package/runners/jest/JestCircusEnvironment.js +3 -38
  53. package/runners/jest/adapter.d.ts +4 -10
  54. package/runners/jest/adapter.js +3 -6
  55. package/runners/jest/assignReporter.d.ts +4 -1
  56. package/runners/jest/assignReporter.js +3 -6
  57. package/runners/jest/deprecation.js +25 -0
  58. package/runners/jest/globalSetup.js +1 -0
  59. package/runners/jest/globalTeardown.js +1 -0
  60. package/runners/jest/index.js +21 -0
  61. package/runners/jest/reporter.js +1 -0
  62. package/runners/jest/reporters/DetoxReporter.js +5 -0
  63. package/runners/jest/specReporter.d.ts +4 -9
  64. package/runners/jest/specReporter.js +3 -10
  65. package/runners/jest/streamlineReporter.js +3 -22
  66. package/runners/jest/testEnvironment/index.js +155 -0
  67. package/runners/{jest-circus → jest/testEnvironment}/listeners/DetoxCoreListener.js +35 -17
  68. package/runners/{jest-circus → jest/testEnvironment}/listeners/DetoxInitErrorListener.js +1 -1
  69. package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +27 -0
  70. package/runners/jest/{SpecReporterImpl.js → testEnvironment/listeners/SpecReporter.js} +61 -7
  71. package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +34 -0
  72. package/runners/jest/testEnvironment/listeners/index.js +13 -0
  73. package/runners/{jest-circus → jest/testEnvironment}/utils/assertExistingContext.js +2 -2
  74. package/runners/jest/testEnvironment/utils/assertJestCircus27.js +56 -0
  75. package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +23 -0
  76. package/runners/jest/{utils → testEnvironment/utils}/getFullTestName.js +0 -0
  77. package/runners/jest/{utils → testEnvironment/utils}/hasTimedOut.js +0 -0
  78. package/runners/jest/{utils → testEnvironment/utils}/index.js +0 -0
  79. package/runners/jest/{utils → testEnvironment/utils}/stdout.js +0 -0
  80. package/runners/jest-circus/environment/index.js +6 -0
  81. package/runners/jest-circus/index.js +1 -10
  82. package/runners/jest-circus/reporter.js +1 -0
  83. package/runners/migration.js +37 -0
  84. package/runners/mocha/DetoxMochaAdapter.js +3 -35
  85. package/runners/mocha/adapter.d.ts +4 -7
  86. package/runners/mocha/adapter.js +3 -5
  87. package/src/{Detox.js → DetoxWorker.js} +131 -164
  88. package/src/artifacts/ArtifactsManager.js +51 -2
  89. package/src/artifacts/providers/index.js +0 -4
  90. package/src/artifacts/utils/buildDefaultArtifactsRootDirpath.js +2 -4
  91. package/src/artifacts/utils/temporaryPath.js +2 -0
  92. package/src/client/AsyncWebSocket.js +1 -1
  93. package/src/client/actions/actions.js +2 -2
  94. package/src/configuration/collectCliConfig.js +2 -4
  95. package/src/configuration/composeAppsConfig.js +8 -66
  96. package/src/configuration/composeArtifactsConfig.js +6 -32
  97. package/src/configuration/composeBehaviorConfig.js +3 -13
  98. package/src/configuration/composeDeviceConfig.js +37 -62
  99. package/src/configuration/composeLoggerConfig.js +50 -0
  100. package/src/configuration/composeRunnerConfig.js +74 -14
  101. package/src/configuration/composeSessionConfig.js +1 -3
  102. package/src/configuration/index.js +24 -23
  103. package/src/configuration/utils/deviceAppTypes.js +0 -1
  104. package/src/devices/allocation/DeviceAllocator.js +3 -3
  105. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +4 -3
  106. package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +2 -6
  107. package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +1 -1
  108. package/src/devices/allocation/drivers/ios/SimulatorLauncher.js +3 -3
  109. package/src/devices/allocation/factories/index.js +0 -1
  110. package/src/devices/common/drivers/DeviceLauncher.js +2 -2
  111. package/src/devices/common/drivers/android/emulator/exec/EmulatorExec.js +1 -1
  112. package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +4 -9
  113. package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +34 -9
  114. package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +1 -1
  115. package/src/devices/runtime/RuntimeDevice.js +69 -81
  116. package/src/devices/runtime/drivers/index.js +0 -1
  117. package/src/devices/runtime/drivers/ios/SimulatorDriver.js +3 -2
  118. package/src/devices/runtime/factories/ios.js +1 -8
  119. package/src/devices/runtime/utils/LaunchArgsEditor.js +4 -59
  120. package/src/devices/runtime/utils/Storage.js +4 -0
  121. package/src/environmentFactory.js +0 -8
  122. package/src/errors/DetoxConfigErrorComposer.js +77 -30
  123. package/src/errors/DetoxError.js +4 -0
  124. package/src/errors/DetoxRuntimeError.js +5 -5
  125. package/src/errors/index.js +2 -0
  126. package/src/ipc/IPCClient.js +117 -0
  127. package/src/ipc/IPCServer.js +87 -0
  128. package/src/ipc/state.js +76 -0
  129. package/src/logger/DetoxLogger.js +244 -0
  130. package/src/logger/DetoxTraceEventBuilder.js +21 -0
  131. package/src/logger/DetoxTracer.js +133 -0
  132. package/src/logger/TraceThreadDispatcher.js +52 -0
  133. package/src/{utils → logger}/customConsoleLogger.js +1 -1
  134. package/src/realms/DetoxConstants.js +13 -0
  135. package/src/realms/DetoxContext.js +170 -0
  136. package/src/realms/DetoxInternalsFacade.js +35 -0
  137. package/src/realms/DetoxPrimaryContext.js +229 -0
  138. package/src/realms/DetoxSecondaryContext.js +94 -0
  139. package/src/realms/index.js +10 -0
  140. package/src/realms/primary.js +3 -0
  141. package/src/realms/secondary.js +3 -0
  142. package/src/server/DetoxConnection.js +1 -1
  143. package/src/symbols.js +56 -0
  144. package/src/utils/Timer.js +14 -6
  145. package/{local-cli/utils/misc.js → src/utils/envUtils.js} +0 -9
  146. package/src/utils/environment.js +30 -15
  147. package/src/utils/logger.js +2 -162
  148. package/src/utils/shellUtils.js +18 -0
  149. package/src/utils/streamUtils.js +214 -0
  150. package/src/utils/trace.js +9 -44
  151. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-javadoc.jar.md5 +0 -1
  152. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-javadoc.jar.sha1 +0 -1
  153. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-javadoc.jar.sha256 +0 -1
  154. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-javadoc.jar.sha512 +0 -1
  155. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-sources.jar.md5 +0 -1
  156. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-sources.jar.sha1 +0 -1
  157. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-sources.jar.sha256 +0 -1
  158. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-sources.jar.sha512 +0 -1
  159. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar +0 -0
  160. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar.md5 +0 -1
  161. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar.sha1 +0 -1
  162. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar.sha256 +0 -1
  163. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar.sha512 +0 -1
  164. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.pom.md5 +0 -1
  165. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.pom.sha1 +0 -1
  166. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.pom.sha256 +0 -1
  167. package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.pom.sha512 +0 -1
  168. package/local-cli/templates/mocha.js +0 -32
  169. package/local-cli/utils/splitArgv.js +0 -107
  170. package/runners/integration.js +0 -16
  171. package/runners/jest/DetoxAdapterCircus.js +0 -60
  172. package/runners/jest/DetoxAdapterImpl.js +0 -81
  173. package/runners/jest/DetoxAdapterJasmine.js +0 -67
  174. package/runners/jest/DetoxStreamlineJestReporter.js +0 -98
  175. package/runners/jest/FailingTestsReporter.js +0 -16
  176. package/runners/jest/SpecReporterCircus.js +0 -51
  177. package/runners/jest/SpecReporterJasmine.js +0 -39
  178. package/runners/jest/WorkerAssignReporterCircus.js +0 -17
  179. package/runners/jest/WorkerAssignReporterImpl.js +0 -21
  180. package/runners/jest/WorkerAssignReporterJasmine.js +0 -15
  181. package/runners/jest/runnerInfo.js +0 -9
  182. package/runners/jest-circus/environment.js +0 -206
  183. package/runners/jest-circus/utils/assertJestCircus26.js +0 -39
  184. package/runners/jest-circus/utils/wrapErrorWithNoopLifecycle.js +0 -14
  185. package/src/DetoxConstants.js +0 -13
  186. package/src/DetoxExportWrapper.js +0 -140
  187. package/src/artifacts/timeline/TimelineArtifactPlugin.js +0 -95
  188. package/src/devices/allocation/drivers/NoneAllocDriver.js +0 -10
  189. package/src/devices/allocation/factories/none.js +0 -11
  190. package/src/index.js +0 -6
  191. package/src/utils/MissingDetox.js +0 -78
  192. package/src/utils/fakeTimestampsProvider.js +0 -9
  193. package/src/utils/getWorkerId.js +0 -5
  194. package/src/utils/lastFailedTests.js +0 -38
  195. package/src/utils/sh.js +0 -18
@@ -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
- });
@@ -1,140 +0,0 @@
1
- // @ts-nocheck
2
- const funpermaproxy = require('funpermaproxy');
3
-
4
- const Detox = require('./Detox');
5
- const DetoxConstants = require('./DetoxConstants');
6
- const configuration = require('./configuration');
7
- const logger = require('./utils/logger');
8
- const log = logger.child({ __filename });
9
- const { trace, traceCall } = require('./utils/trace');
10
-
11
- const _detox = Symbol('detox');
12
- const _shouldLogInitError = Symbol('shouldLogInitError');
13
-
14
- class DetoxExportWrapper {
15
- constructor() {
16
- this[_detox] = Detox.none;
17
- this[_shouldLogInitError] = true;
18
-
19
- this.init = this.init.bind(this);
20
- this.cleanup = this.cleanup.bind(this);
21
-
22
- this.DetoxConstants = DetoxConstants;
23
-
24
- this._definePassthroughMethod('beforeEach');
25
- this._definePassthroughMethod('afterEach');
26
- this._definePassthroughMethod('suiteStart');
27
- this._definePassthroughMethod('suiteEnd');
28
-
29
- this._definePassthroughMethod('element');
30
- this._definePassthroughMethod('expect');
31
- this._definePassthroughMethod('waitFor');
32
-
33
- this._defineProxy('by');
34
- this._defineProxy('device');
35
- this._defineProxy('web');
36
-
37
- this.trace = trace;
38
- this.traceCall = traceCall;
39
- }
40
-
41
- async init(configOverride, userParams) {
42
- let configError, exposeGlobals, resolvedConfig;
43
-
44
- trace.init();
45
- logger.reinitialize(Detox.global);
46
-
47
- try {
48
- resolvedConfig = await configuration.composeDetoxConfig({
49
- override: configOverride,
50
- userParams,
51
- });
52
-
53
- exposeGlobals = resolvedConfig.behaviorConfig.init.exposeGlobals;
54
- } catch (err) {
55
- configError = err;
56
- exposeGlobals = true;
57
- }
58
-
59
- try {
60
- if (exposeGlobals) {
61
- Detox.none.initContext(Detox.global);
62
- }
63
-
64
- if (configError) {
65
- throw configError;
66
- }
67
-
68
- this[_detox] = new Detox(resolvedConfig);
69
- await traceCall('detoxInit', () => this[_detox].init());
70
- Detox.none.setError(null);
71
-
72
- return this[_detox];
73
- } catch (err) {
74
- if (this[_shouldLogInitError]) {
75
- log.error({ event: 'DETOX_INIT_ERROR' }, '\n', err);
76
- }
77
-
78
- Detox.none.setError(err);
79
- throw err;
80
- }
81
- }
82
-
83
- async cleanup() {
84
- Detox.none.cleanupContext(Detox.global);
85
-
86
- if (this[_detox] !== Detox.none) {
87
- await this[_detox].cleanup();
88
- this[_detox] = Detox.none;
89
- }
90
- }
91
-
92
- _definePassthroughMethod(name) {
93
- this[name] = (...args) => {
94
- return this[_detox][name](...args);
95
- };
96
- }
97
-
98
- _defineProxy(name) {
99
- this[name] = funpermaproxy(() => this[_detox][name]);
100
- }
101
-
102
- /** Use for test runners with sandboxed global */
103
- _setGlobal(global) {
104
- Detox.global = global;
105
- return this;
106
- }
107
-
108
- /** @internal */
109
- _suppressLoggingInitErrors() {
110
- this[_shouldLogInitError] = false;
111
- return this;
112
- }
113
- }
114
-
115
- DetoxExportWrapper.prototype.hook = configuration.hook;
116
-
117
- DetoxExportWrapper.prototype.globalInit = async function() {
118
- try {
119
- // TODO This can only work in Jest, where config info etc. is available globally through env vars rather
120
- // than argv (e.g. in Mocha) -- which we don't have available here.
121
- // We will resolve this, ultimately, in https://github.com/wix/Detox/issues/2894 (DAS project), where
122
- // this whole hack would be removed altogether.
123
- const configs = await configuration.composeDetoxConfig({});
124
- await Detox.globalInit(configs);
125
- } catch (error) {
126
- log.warn({ event: 'GLOBAL_INIT' }, 'An error occurred!');
127
- throw error;
128
- }
129
- };
130
-
131
- DetoxExportWrapper.prototype.globalCleanup = async function() {
132
- try {
133
- const configs = await configuration.composeDetoxConfig({});
134
- await Detox.globalCleanup(configs);
135
- } catch (error) {
136
- log.warn({ event: 'GLOBAL_CLEANUP' }, 'An error occurred!', error);
137
- }
138
- };
139
-
140
- module.exports = DetoxExportWrapper;
@@ -1,95 +0,0 @@
1
- const fs = require('fs-extra');
2
- const _noop = require('lodash/noop');
3
-
4
- const ChromeTracingExporter = require('../../utils/ChromeTracingExporter');
5
- const fakeTimestampsProvider = require('../../utils/fakeTimestampsProvider');
6
- const { trace } = require('../../utils/trace');
7
- const FileArtifact = require('../templates/artifact/FileArtifact');
8
- const ArtifactPlugin = require('../templates/plugin/ArtifactPlugin');
9
-
10
- const traceNoop = {
11
- startSection: _noop,
12
- endSection: _noop,
13
- };
14
-
15
- const CONTEXT_TYPES = {
16
- TEST: 'test',
17
- DESCRIBE: 'describe'
18
- };
19
-
20
- class TimelineArtifactPlugin extends ArtifactPlugin {
21
- constructor(config) {
22
- super(config);
23
- this._useFakeTimestamps = config.useFakeTimestamps;
24
-
25
- const threadId = process.env.JEST_WORKER_ID || process.pid;
26
- this._trace = this.enabled ? trace : traceNoop;
27
- this._traceExporter = new ChromeTracingExporter({
28
- process: { id: 0, name: 'detox' },
29
- thread: { id: threadId, name: `Worker #${threadId}` },
30
- });
31
- }
32
-
33
- async onBootDevice(event) {
34
- this._deviceName = event.deviceId;
35
- return super.onBootDevice(event);
36
- }
37
-
38
- async onRunDescribeStart(suite) {
39
- const sectionName = (suite.name === 'ROOT_DESCRIBE_BLOCK' ? this._deviceName : suite.name);
40
- this._trace.startSection(sectionName, { context: CONTEXT_TYPES.DESCRIBE });
41
- await super.onRunDescribeStart(suite);
42
- }
43
-
44
- async onRunDescribeFinish(suite) {
45
- const sectionName = (suite.name === 'ROOT_DESCRIBE_BLOCK' ? this._deviceName : suite.name);
46
- this._trace.endSection(sectionName, { context: CONTEXT_TYPES.DESCRIBE });
47
- await super.onRunDescribeFinish(suite);
48
- }
49
-
50
- async onTestStart(testSummary) {
51
- this._trace.startSection(testSummary.title, { context: CONTEXT_TYPES.TEST });
52
- await super.onTestStart(testSummary);
53
- }
54
-
55
- async onTestDone(testSummary) {
56
- this._trace.endSection(testSummary.title, { status: testSummary.status, context: CONTEXT_TYPES.TEST });
57
- await super.onTestDone(testSummary);
58
- }
59
-
60
- async onBeforeCleanup() {
61
- this._deviceName = null;
62
-
63
- if (!this.enabled) {
64
- return;
65
- }
66
-
67
- const traceLogPath = await this.api.preparePathForArtifact(`detox.trace.json`);
68
- const append = await this._logFileExists(traceLogPath);
69
- const events = this._useFakeTimestamps ? this._transformEventTimestamps(trace.events) : trace.events;
70
- const data = this._traceExporter.export(events, append);
71
-
72
- const fileArtifact = new FileArtifact({ temporaryData: data });
73
- await fileArtifact.save(traceLogPath, { append });
74
- }
75
-
76
- async _logFileExists(traceLogPath) {
77
- return fs.access(traceLogPath).then(() => true).catch(() => false);
78
- }
79
-
80
- _transformEventTimestamps(events) {
81
- return events.map((event) => ({
82
- ...event,
83
- ts: fakeTimestampsProvider(),
84
- }));
85
- }
86
-
87
- /** @param {string} config */
88
- static parseConfig(config) {
89
- return {
90
- enabled: config === 'all',
91
- };
92
- }
93
- }
94
-
95
- module.exports = TimelineArtifactPlugin;
@@ -1,10 +0,0 @@
1
- const AllocationDriverBase = require('./AllocationDriverBase');
2
-
3
- class NoneAllocDriver extends AllocationDriverBase {
4
- async allocate(deviceQuery) { // eslint-disable-line no-unused-vars
5
- return null;
6
- }
7
- async free(cookie, options) {} // eslint-disable-line no-unused-vars
8
- }
9
-
10
- module.exports = NoneAllocDriver;
@@ -1,11 +0,0 @@
1
- // @ts-nocheck
2
- const DeviceAllocatorFactory = require('./base');
3
-
4
- class None extends DeviceAllocatorFactory {
5
- _createDriver() {
6
- const NoneAllocDriver = require('../drivers/NoneAllocDriver');
7
- return new NoneAllocDriver();
8
- }
9
- }
10
-
11
- module.exports = { None };
package/src/index.js DELETED
@@ -1,6 +0,0 @@
1
- if (global.detox) {
2
- module.exports = global.detox;
3
- } else {
4
- const DetoxExportWrapper = require('./DetoxExportWrapper');
5
- module.exports = new DetoxExportWrapper();
6
- }
@@ -1,78 +0,0 @@
1
- const DetoxRuntimeError = require('../errors/DetoxRuntimeError');
2
-
3
- class MissingDetox {
4
- constructor() {
5
- this.throwError = this.throwError.bind(this);
6
- this.initContext(this);
7
-
8
- this._defineRequiredProperty(this, 'beforeEach', async () => this.throwError(), true);
9
- this._defineRequiredProperty(this, 'afterEach', async () => this.throwError(), true);
10
- }
11
-
12
- initContext(context) {
13
- const readonly = context === this;
14
-
15
- this._defineRequiredProperty(context, 'by', undefined, readonly);
16
- this._defineRequiredProperty(context, 'device', undefined, readonly);
17
- this._defineRequiredProperty(context, 'element', this.throwError, readonly);
18
- this._defineRequiredProperty(context, 'expect', this.throwError, readonly);
19
- this._defineRequiredProperty(context, 'waitFor', this.throwError, readonly);
20
- this._defineRequiredProperty(context, 'web', undefined, readonly);
21
- }
22
-
23
- cleanupContext(context) {
24
- this._cleanupProperty(context, 'by');
25
- this._cleanupProperty(context, 'device');
26
- this._cleanupProperty(context, 'element');
27
- this._cleanupProperty(context, 'expect');
28
- this._cleanupProperty(context, 'waitFor');
29
- }
30
-
31
- _cleanupProperty(context, name) {
32
- if (context.hasOwnProperty(name)) {
33
- context[name] = undefined;
34
- }
35
- }
36
-
37
- _defineRequiredProperty(context, name, initialValue, readonly) {
38
- if (context.hasOwnProperty(name)) {
39
- return;
40
- }
41
-
42
- let _value = initialValue;
43
-
44
- const descriptor = {
45
- get: () => {
46
- if (_value === undefined) {
47
- this.throwError();
48
- }
49
-
50
- return _value;
51
- },
52
- };
53
-
54
- if (!readonly) {
55
- descriptor.set = (value) => {
56
- _value = value;
57
- };
58
- }
59
-
60
- Object.defineProperty(context, name, descriptor);
61
- }
62
-
63
- setError(err) {
64
- this._lastError = err;
65
- }
66
-
67
- throwError() {
68
- throw new DetoxRuntimeError({
69
- message: 'Detox instance has not been initialized',
70
- hint: this._lastError
71
- ? 'There was an error on attempt to call detox.init()'
72
- : 'Make sure to call detox.init() before your test begins',
73
- debugInfo: this._lastError && this._lastError.stack || '',
74
- });
75
- }
76
- }
77
-
78
- module.exports = MissingDetox;
@@ -1,9 +0,0 @@
1
- let _timestamp = 1000;
2
-
3
- function nextTimestamp() {
4
- const timestamp = _timestamp;
5
- _timestamp += 100;
6
- return timestamp;
7
- }
8
-
9
- module.exports = nextTimestamp;
@@ -1,5 +0,0 @@
1
- function getWorkerId() {
2
- return process.env.JEST_WORKER_ID;
3
- }
4
-
5
- module.exports = getWorkerId;
@@ -1,38 +0,0 @@
1
- const fs = require('fs-extra');
2
-
3
- const environment = require('./environment');
4
-
5
- async function resetLastFailedTests() {
6
- const lastFailedTxt = environment.getLastFailedTestsPath();
7
- await fs.remove(lastFailedTxt);
8
- }
9
-
10
- async function loadLastFailedTests() {
11
- const lastFailedTxt = environment.getLastFailedTestsPath();
12
- const lastFailedTests = await fs.exists(lastFailedTxt)
13
- ? (await fs.readFile(lastFailedTxt, 'utf8')).trim()
14
- : '';
15
-
16
- if (lastFailedTests) {
17
- return lastFailedTests.split('\n');
18
- } else {
19
- return [];
20
- }
21
- }
22
-
23
- /**
24
- * @async
25
- * @param {string[]} failedFiles - paths to the test suites
26
- */
27
- async function saveLastFailedTests(failedFiles) {
28
- const failedTestsPath = environment.getLastFailedTestsPath();
29
-
30
- await fs.ensureFile(failedTestsPath);
31
- await fs.writeFile(failedTestsPath, failedFiles.join('\n'));
32
- }
33
-
34
- module.exports = {
35
- resetLastFailedTests,
36
- loadLastFailedTests,
37
- saveLastFailedTests,
38
- };
package/src/utils/sh.js DELETED
@@ -1,18 +0,0 @@
1
- // @ts-nocheck
2
- const cpp = require('child-process-promise');
3
-
4
- const sh = new Proxy({}, {
5
- get: function(target, prop) {
6
- if (target[prop] === undefined) {
7
- return target[prop] = (...params) => {
8
- return cpp.exec(`${prop} ${params.join(' ')}`);
9
- };
10
- } else {
11
- return target[prop];
12
- }
13
- }
14
- });
15
-
16
- process.env['PATH'] = `${process.env.PATH}:${sh.npm(`bin`)}`;
17
-
18
- module.exports = sh;