detox 19.7.1 → 20.0.0-breaking.new-global-lifecycle.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. package/Detox-android/com/wix/detox/{19.7.1/detox-19.7.1-javadoc.jar → 20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar} +0 -0
  2. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +1 -0
  5. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +1 -0
  6. package/Detox-android/com/wix/detox/{19.7.1/detox-19.7.1-sources.jar → 20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar} +0 -0
  7. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar.sha512 +1 -0
  11. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar +0 -0
  12. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar.md5 +1 -0
  13. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar.sha1 +1 -0
  14. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar.sha256 +1 -0
  15. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar.sha512 +1 -0
  16. package/Detox-android/com/wix/detox/{19.7.1/detox-19.7.1.pom → 20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.pom} +1 -1
  17. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.pom.md5 +1 -0
  18. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.pom.sha1 +1 -0
  19. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.pom.sha256 +1 -0
  20. package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-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/espresso/DetoxAction.java +3 -1
  31. package/android/detox/src/full/java/com/wix/detox/espresso/matcher/ViewMatchers.kt +23 -16
  32. package/android/detox/src/main/java/com/wix/detox/common/DetoxErrors.java +1 -0
  33. package/android/detox/src/main/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +36 -0
  34. package/android/detox/src/{full → main}/java/com/wix/detox/espresso/action/GetAttributesAction.kt +1 -13
  35. package/android/detox/src/testFull/java/com/wix/detox/espresso/action/AdjustSliderToPositionActionTest.kt +59 -0
  36. package/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt +3 -15
  37. package/index.d.ts +208 -186
  38. package/index.js +1 -0
  39. package/internals.d.ts +129 -0
  40. package/internals.js +4 -0
  41. package/local-cli/build-framework-cache.js +2 -2
  42. package/local-cli/build.js +7 -8
  43. package/local-cli/build.test.js +46 -40
  44. package/local-cli/clean-framework-cache.js +3 -3
  45. package/local-cli/cli.js +0 -1
  46. package/local-cli/init.js +20 -55
  47. package/local-cli/templates/jest.js +9 -34
  48. package/local-cli/test.js +18 -282
  49. package/local-cli/test.test.js +332 -673
  50. package/local-cli/testCommand/TestRunnerCommand.js +156 -0
  51. package/local-cli/{utils/testCommandArgs.js → testCommand/builder.js} +10 -35
  52. package/local-cli/testCommand/middlewares.js +75 -0
  53. package/local-cli/{utils → testCommand}/warnings.js +0 -10
  54. package/local-cli/utils/jestInternals.js +13 -2
  55. package/local-cli/utils/yargsUtils.js +67 -0
  56. package/package.json +27 -21
  57. package/runners/deprecation.js +47 -0
  58. package/runners/jest/JestCircusEnvironment.js +3 -38
  59. package/runners/jest/adapter.d.ts +4 -10
  60. package/runners/jest/adapter.js +3 -6
  61. package/runners/jest/assignReporter.d.ts +4 -1
  62. package/runners/jest/assignReporter.js +3 -6
  63. package/runners/jest/deprecation.js +25 -0
  64. package/runners/jest/globalSetup.js +1 -0
  65. package/runners/jest/globalTeardown.js +1 -0
  66. package/runners/jest/index.js +21 -0
  67. package/runners/jest/reporter.js +1 -0
  68. package/runners/jest/reporters/DetoxReporter.js +5 -0
  69. package/runners/jest/specReporter.d.ts +4 -9
  70. package/runners/jest/specReporter.js +3 -10
  71. package/runners/jest/streamlineReporter.js +3 -22
  72. package/runners/jest/testEnvironment/index.js +155 -0
  73. package/runners/{jest-circus → jest/testEnvironment}/listeners/DetoxCoreListener.js +35 -17
  74. package/runners/{jest-circus → jest/testEnvironment}/listeners/DetoxInitErrorListener.js +1 -1
  75. package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +27 -0
  76. package/runners/jest/{SpecReporterImpl.js → testEnvironment/listeners/SpecReporter.js} +61 -7
  77. package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +34 -0
  78. package/runners/jest/testEnvironment/listeners/index.js +13 -0
  79. package/runners/{jest-circus → jest/testEnvironment}/utils/assertExistingContext.js +2 -2
  80. package/runners/jest/testEnvironment/utils/assertJestCircus27.js +56 -0
  81. package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +23 -0
  82. package/runners/jest/{utils → testEnvironment/utils}/getFullTestName.js +0 -0
  83. package/runners/jest/{utils → testEnvironment/utils}/hasTimedOut.js +0 -0
  84. package/runners/jest/{utils → testEnvironment/utils}/index.js +0 -0
  85. package/runners/jest/{utils → testEnvironment/utils}/stdout.js +0 -0
  86. package/runners/jest-circus/environment/index.js +6 -0
  87. package/runners/jest-circus/index.js +1 -10
  88. package/runners/jest-circus/reporter.js +1 -0
  89. package/runners/migration.js +37 -0
  90. package/runners/mocha/DetoxMochaAdapter.js +3 -35
  91. package/runners/mocha/adapter.d.ts +4 -7
  92. package/runners/mocha/adapter.js +3 -5
  93. package/src/{Detox.js → DetoxWorker.js} +130 -168
  94. package/src/artifacts/ArtifactsManager.js +51 -2
  95. package/src/artifacts/log/android/ADBLogcatRecording.js +28 -11
  96. package/src/artifacts/providers/index.js +0 -4
  97. package/src/artifacts/utils/buildDefaultArtifactsRootDirpath.js +2 -4
  98. package/src/artifacts/utils/temporaryPath.js +2 -0
  99. package/src/client/AsyncWebSocket.js +1 -1
  100. package/src/client/actions/actions.js +2 -2
  101. package/src/configuration/collectCliConfig.js +2 -4
  102. package/src/configuration/composeAppsConfig.js +9 -67
  103. package/src/configuration/composeArtifactsConfig.js +6 -32
  104. package/src/configuration/composeBehaviorConfig.js +3 -13
  105. package/src/configuration/composeDeviceConfig.js +37 -62
  106. package/src/configuration/composeLoggerConfig.js +50 -0
  107. package/src/configuration/composeRunnerConfig.js +74 -14
  108. package/src/configuration/composeSessionConfig.js +1 -3
  109. package/src/configuration/index.js +24 -23
  110. package/src/configuration/utils/deviceAppTypes.js +0 -1
  111. package/src/devices/allocation/DeviceAllocator.js +3 -3
  112. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +4 -3
  113. package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +2 -6
  114. package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +1 -1
  115. package/src/devices/allocation/drivers/ios/SimulatorLauncher.js +3 -3
  116. package/src/devices/allocation/factories/index.js +0 -1
  117. package/src/devices/common/drivers/DeviceLauncher.js +2 -2
  118. package/src/devices/common/drivers/android/emulator/exec/EmulatorExec.js +1 -1
  119. package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +4 -9
  120. package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +34 -9
  121. package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +1 -1
  122. package/src/devices/runtime/RuntimeDevice.js +69 -81
  123. package/src/devices/runtime/drivers/index.js +0 -1
  124. package/src/devices/runtime/drivers/ios/SimulatorDriver.js +3 -2
  125. package/src/devices/runtime/factories/ios.js +1 -8
  126. package/src/devices/runtime/utils/LaunchArgsEditor.js +4 -59
  127. package/src/devices/runtime/utils/Storage.js +4 -0
  128. package/src/environmentFactory.js +0 -8
  129. package/src/errors/DetoxConfigErrorComposer.js +76 -29
  130. package/src/errors/DetoxError.js +4 -0
  131. package/src/errors/DetoxRuntimeError.js +5 -5
  132. package/src/errors/index.js +2 -0
  133. package/src/ipc/IPCClient.js +117 -0
  134. package/src/ipc/IPCServer.js +81 -0
  135. package/src/ipc/state.js +67 -0
  136. package/src/logger/DetoxLogger.js +244 -0
  137. package/src/logger/DetoxTraceEventBuilder.js +21 -0
  138. package/src/logger/DetoxTracer.js +133 -0
  139. package/src/logger/TraceThreadDispatcher.js +52 -0
  140. package/src/{utils → logger}/customConsoleLogger.js +1 -1
  141. package/src/realms/DetoxConstants.js +13 -0
  142. package/src/realms/DetoxContext.js +170 -0
  143. package/src/realms/DetoxInternalsFacade.js +35 -0
  144. package/src/realms/DetoxPrimaryContext.js +228 -0
  145. package/src/realms/DetoxSecondaryContext.js +93 -0
  146. package/src/realms/index.js +10 -0
  147. package/src/realms/primary.js +3 -0
  148. package/src/realms/secondary.js +3 -0
  149. package/src/server/DetoxConnection.js +1 -1
  150. package/src/symbols.js +56 -0
  151. package/src/utils/Timer.js +14 -6
  152. package/{local-cli/utils/misc.js → src/utils/envUtils.js} +0 -9
  153. package/src/utils/logger.js +2 -162
  154. package/src/utils/shellUtils.js +18 -0
  155. package/src/utils/streamUtils.js +214 -0
  156. package/src/utils/trace.js +9 -44
  157. package/Detox-android/com/wix/detox/19.7.1/detox-19.7.1-javadoc.jar.md5 +0 -1
  158. package/Detox-android/com/wix/detox/19.7.1/detox-19.7.1-javadoc.jar.sha1 +0 -1
  159. package/Detox-android/com/wix/detox/19.7.1/detox-19.7.1-javadoc.jar.sha256 +0 -1
  160. package/Detox-android/com/wix/detox/19.7.1/detox-19.7.1-javadoc.jar.sha512 +0 -1
  161. package/Detox-android/com/wix/detox/19.7.1/detox-19.7.1-sources.jar.md5 +0 -1
  162. package/Detox-android/com/wix/detox/19.7.1/detox-19.7.1-sources.jar.sha1 +0 -1
  163. package/Detox-android/com/wix/detox/19.7.1/detox-19.7.1-sources.jar.sha256 +0 -1
  164. package/Detox-android/com/wix/detox/19.7.1/detox-19.7.1-sources.jar.sha512 +0 -1
  165. package/Detox-android/com/wix/detox/19.7.1/detox-19.7.1.aar +0 -0
  166. package/Detox-android/com/wix/detox/19.7.1/detox-19.7.1.aar.md5 +0 -1
  167. package/Detox-android/com/wix/detox/19.7.1/detox-19.7.1.aar.sha1 +0 -1
  168. package/Detox-android/com/wix/detox/19.7.1/detox-19.7.1.aar.sha256 +0 -1
  169. package/Detox-android/com/wix/detox/19.7.1/detox-19.7.1.aar.sha512 +0 -1
  170. package/Detox-android/com/wix/detox/19.7.1/detox-19.7.1.pom.md5 +0 -1
  171. package/Detox-android/com/wix/detox/19.7.1/detox-19.7.1.pom.sha1 +0 -1
  172. package/Detox-android/com/wix/detox/19.7.1/detox-19.7.1.pom.sha256 +0 -1
  173. package/Detox-android/com/wix/detox/19.7.1/detox-19.7.1.pom.sha512 +0 -1
  174. package/android/detox/src/full/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +0 -22
  175. package/android/detox/src/full/java/com/wix/detox/espresso/common/SliderHelper.kt +0 -75
  176. package/android/detox/src/main/java/com/wix/detox/espresso/action/common/ReflectUtils.kt +0 -10
  177. package/android/detox/src/testFull/java/com/wix/detox/espresso/common/SliderHelperTest.kt +0 -39
  178. package/local-cli/templates/mocha.js +0 -32
  179. package/local-cli/utils/splitArgv.js +0 -107
  180. package/runners/integration.js +0 -16
  181. package/runners/jest/DetoxAdapterCircus.js +0 -60
  182. package/runners/jest/DetoxAdapterImpl.js +0 -81
  183. package/runners/jest/DetoxAdapterJasmine.js +0 -67
  184. package/runners/jest/DetoxStreamlineJestReporter.js +0 -98
  185. package/runners/jest/FailingTestsReporter.js +0 -16
  186. package/runners/jest/SpecReporterCircus.js +0 -51
  187. package/runners/jest/SpecReporterJasmine.js +0 -39
  188. package/runners/jest/WorkerAssignReporterCircus.js +0 -17
  189. package/runners/jest/WorkerAssignReporterImpl.js +0 -21
  190. package/runners/jest/WorkerAssignReporterJasmine.js +0 -15
  191. package/runners/jest/runnerInfo.js +0 -9
  192. package/runners/jest-circus/environment.js +0 -206
  193. package/runners/jest-circus/utils/assertJestCircus26.js +0 -39
  194. package/runners/jest-circus/utils/wrapErrorWithNoopLifecycle.js +0 -14
  195. package/src/DetoxConstants.js +0 -13
  196. package/src/DetoxExportWrapper.js +0 -140
  197. package/src/artifacts/timeline/TimelineArtifactPlugin.js +0 -90
  198. package/src/devices/allocation/drivers/NoneAllocDriver.js +0 -10
  199. package/src/devices/allocation/factories/none.js +0 -11
  200. package/src/index.js +0 -6
  201. package/src/utils/MissingDetox.js +0 -78
  202. package/src/utils/fakeTimestampsProvider.js +0 -9
  203. package/src/utils/getWorkerId.js +0 -5
  204. package/src/utils/lastFailedTests.js +0 -38
  205. package/src/utils/sh.js +0 -18
@@ -1,32 +0,0 @@
1
- const firstTestContent = require('./firstTestContent');
2
-
3
- const mochaRcContent = JSON.stringify({
4
- recursive: true,
5
- timeout: 120000,
6
- bail: true,
7
- file: 'e2e/init.js',
8
- }, null, 4);
9
-
10
- const initjsContent = `const detox = require('detox');
11
- const adapter = require('detox/runners/mocha/adapter');
12
-
13
- before(async () => {
14
- await detox.init();
15
- });
16
-
17
- beforeEach(async function () {
18
- await adapter.beforeEach(this);
19
- });
20
-
21
- afterEach(async function () {
22
- await adapter.afterEach(this);
23
- });
24
-
25
- after(async () => {
26
- await detox.cleanup();
27
- });
28
- `;
29
-
30
- exports.initjs = initjsContent;
31
- exports.firstTest = firstTestContent;
32
- exports.runnerConfig = mochaRcContent;
@@ -1,107 +0,0 @@
1
- const _ = require('lodash');
2
-
3
- const { resolveJestCliArgs } = require('./jestInternals');
4
- const testCommandArgs = require('./testCommandArgs');
5
-
6
- function extractKnownKeys(yargsBuilder) {
7
- return Object.entries(yargsBuilder).reduce(
8
- (set, [key, option]) => {
9
- if (option.alias) {
10
- if (Array.isArray(option.alias)) {
11
- for (const value of option.alias) {
12
- set.add(value);
13
- }
14
- } else {
15
- set.add(option.alias);
16
- }
17
- }
18
-
19
- return set.add(key);
20
- },
21
- new Set()
22
- );
23
- }
24
-
25
- function disengageBooleanArgs(argv, booleanKeys) {
26
- const result = {};
27
- const passthrough = [];
28
-
29
- for (const entry of Object.entries(argv)) {
30
- const [key, value] = entry;
31
- if (key === '_' || key === '--') {
32
- continue;
33
- }
34
-
35
- const positiveKey = key.startsWith('no-') ? key.slice(3) : key;
36
- if (booleanKeys.has(positiveKey) && typeof value !== 'boolean') {
37
- result[positiveKey] = key === positiveKey;
38
- passthrough.push(value);
39
- } else {
40
- result[key] = value;
41
- }
42
- }
43
-
44
- return {
45
- specs: passthrough.concat(argv._),
46
- passthrough: {
47
- _: argv['--'] || [],
48
- ...result,
49
- },
50
- };
51
- }
52
-
53
- function getJestBooleanArgs() {
54
- return _(resolveJestCliArgs())
55
- .thru(args => args.options)
56
- .pickBy(({ type }) => type === 'boolean')
57
- .thru(extractKnownKeys)
58
- .value();
59
- }
60
-
61
- function getMochaBooleanArgs() {
62
- const metadata = require('mocha/lib/cli/run-option-metadata');
63
-
64
- return _(metadata.types.boolean)
65
- .flatMap(key => [key, ...(metadata.aliases[key] || [])])
66
- .thru(keys => new Set(keys))
67
- .value();
68
- }
69
-
70
- function splitDetoxArgv(argv) {
71
- const aliases = extractKnownKeys(testCommandArgs);
72
- const isDetoxArg = (_value, key) => aliases.has(key);
73
-
74
- const detoxArgs = _.pickBy(argv, isDetoxArg);
75
- const runnerArgs = _.omitBy(argv, isDetoxArg);
76
- runnerArgs._ = runnerArgs._.slice(1); // omit 'test' string, as in 'detox test'
77
- if (typeof detoxArgs['debug-synchronization'] === 'string') {
78
- const erroneousPassthrough = detoxArgs['debug-synchronization'];
79
- detoxArgs['debug-synchronization'] = 3000;
80
- runnerArgs._.unshift(erroneousPassthrough);
81
- }
82
-
83
- return { detoxArgs, runnerArgs };
84
- }
85
-
86
- function splitMochaArgv(argv) {
87
- return disengageBooleanArgs(argv, getMochaBooleanArgs());
88
- }
89
-
90
- function splitJestArgv(argv) {
91
- return realiasJestArgv(disengageBooleanArgs(argv, getJestBooleanArgs()));
92
- }
93
-
94
- function realiasJestArgv({ specs, passthrough }) {
95
- if (passthrough.hasOwnProperty('t')) {
96
- passthrough.testNamePattern = passthrough.t;
97
- delete passthrough.t;
98
- }
99
-
100
- return { specs, passthrough };
101
- }
102
-
103
- module.exports = {
104
- detox: splitDetoxArgv,
105
- jest: splitJestArgv,
106
- mocha: splitMochaArgv,
107
- };
@@ -1,16 +0,0 @@
1
- module.exports = {
2
- lifecycle: {
3
- onRunStart: Symbol('run_start'),
4
- onRunDescribeStart: Symbol('run_describe_start'),
5
- onTestStart: Symbol('test_start'),
6
- onHookStart: Symbol('hook_start'),
7
- onHookFailure: Symbol('hook_failure'),
8
- onHookSuccess: Symbol('hook_success'),
9
- onTestFnStart: Symbol('test_fn_start'),
10
- onTestFnFailure: Symbol('test_fn_failure'),
11
- onTestFnSuccess: Symbol('test_fn_success'),
12
- onTestDone: Symbol('test_done'),
13
- onRunDescribeFinish: Symbol('run_describe_finish'),
14
- onRunFinish: Symbol('run_finish'),
15
- },
16
- };
@@ -1,60 +0,0 @@
1
- const DetoxAdapter = require('./DetoxAdapterImpl');
2
- const { getFullTestName, hasTimedOut } = require('./utils');
3
-
4
- class DetoxAdapterCircus {
5
- constructor(detox) {
6
- this._adapter = new DetoxAdapter(detox, DetoxAdapterCircus._describeInitError);
7
- }
8
-
9
- static _describeInitError() {
10
- return {
11
- message: 'Detox adapter to Jest is malfunctioning.',
12
- hint: `Make sure you register it as a test-event listener inside init.js:\n` +
13
- `-------------------------------------------------------------\n` +
14
- 'detoxCircus.getEnv().addEventsListener(adapter);',
15
- };
16
- }
17
-
18
- async beforeEach() {
19
- await this._adapter.beforeEach();
20
- }
21
-
22
- async afterAll() {
23
- await this._adapter.afterAll();
24
- }
25
-
26
- async run_describe_start({ describeBlock: { name, children } }, state) { // eslint-disable-line no-unused-vars
27
- if (children.length) await this._adapter.suiteStart({ name });
28
- }
29
-
30
- async run_describe_finish({ describeBlock: { name, children } }, state) { // eslint-disable-line no-unused-vars
31
- if (children.length) await this._adapter.suiteEnd({ name });
32
- }
33
-
34
- test_start(event) {
35
- const { test } = event;
36
- if (test.mode === 'skip' || test.mode === 'todo' || test.errors.length > 0) {
37
- return;
38
- }
39
-
40
- this._adapter.testStart({
41
- title: test.name,
42
- fullName: getFullTestName(test),
43
- status: 'running',
44
- });
45
- }
46
-
47
- test_done(event) {
48
- const { test } = event;
49
- this._adapter.testComplete({
50
- status: test.errors.length ? 'failed' : 'passed',
51
- timedOut: hasTimedOut(test)
52
- });
53
- }
54
-
55
- test_skip(event) { // eslint-disable-line no-unused-vars
56
- // Ignored (for clarity)
57
- }
58
- }
59
-
60
- module.exports = DetoxAdapterCircus;
@@ -1,81 +0,0 @@
1
- const DetoxRuntimeError = require('../../src/errors/DetoxRuntimeError');
2
- const log = require('../../src/utils/logger').child({ __filename });
3
-
4
- class DetoxAdapterImpl {
5
- constructor(detox, describeInitErrorFn) {
6
- if (process.env.DETOX_RERUN_INDEX) {
7
- log.warn(
8
- 'While Detox CLI supports "-R <N>, --retries <N>" mechanism, ' +
9
- 'this outdated Jest integration does not — expect artifacts issues. ' +
10
- 'Please migrate to the new Jest Circus integration.\n\n' +
11
- 'See: https://wix.github.io/Detox/docs/api/guide/jest\n');
12
- }
13
-
14
- this.detox = detox;
15
- this._describeInitError = describeInitErrorFn;
16
- this._currentTest = null;
17
- this._todos = [];
18
- }
19
-
20
- async beforeEach() {
21
- if (!this._currentTest) {
22
- throw new DetoxRuntimeError(this._describeInitError());
23
- }
24
-
25
- const currentTest = this._currentTest;
26
-
27
- await this._flush();
28
- await this.detox.beforeEach(currentTest);
29
- }
30
-
31
- async afterAll() {
32
- await this._flush();
33
- }
34
-
35
- async suiteStart({ name }) {
36
- this._enqueue(() => this.detox.suiteStart({ name }));
37
- }
38
-
39
- async suiteEnd({ name }) {
40
- this._enqueue(() => this.detox.suiteEnd({ name }));
41
- }
42
-
43
- testStart({ title, fullName, status }) {
44
- this._currentTest = {
45
- title,
46
- fullName,
47
- status,
48
- };
49
- }
50
-
51
- testComplete({ status, timedOut }) {
52
- if (this._currentTest) {
53
- const _test = {
54
- ...this._currentTest,
55
- status,
56
- timedOut,
57
- };
58
-
59
- this._currentTest = null;
60
- this._enqueue(() => this._afterEach(_test));
61
- }
62
- }
63
-
64
- async _afterEach(previousTest) {
65
- await this.detox.afterEach(previousTest);
66
- }
67
-
68
- _enqueue(fn) {
69
- this._todos.push(fn);
70
- }
71
-
72
- async _flush() {
73
- const t = this._todos;
74
-
75
- while (t.length > 0) {
76
- await Promise.resolve().then(t.shift()).catch(()=>{});
77
- }
78
- }
79
- }
80
-
81
- module.exports = DetoxAdapterImpl;
@@ -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
- };